此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
% k2 w9 X& B# s& c" h6 _ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! V3 s% m" L+ F3 n% b( x: D
方式一:
t5 d3 n/ X" F6 g4 Q 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
+ z8 W1 T7 v; D! `$ F- j/ o/ S 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
& T9 ?# t! e7 u( e" D HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" |2 \( ^* o! w. t- z
方式二:' v* w; s( V- B
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:" U, P' ~' i: E* l. J, O
SetTitleMatchMode RegEx1 y! g! I' s7 r* ^& g3 A
return* k& J. M5 |. x7 a+ l& x- X
; Stuff to do when Windows Explorer is open
% q# r9 T7 m! H8 m/ X4 C. f ;3 t/ T8 y/ p, @* B( @* D
#IfWinActive ahk_class ExploreWClass|CabinetWClass8 V: l- j l4 G; J
; open ‘cmd’ in the current directory2 j0 [% C- ]4 \9 K* |$ B
;
/ e. B& r* A2 r. R) C5 e #c::
! o1 }4 b: Q# v0 o3 f( W+ u! v( ~ OpenCmdInCurrent()+ c! R9 r0 O5 \) \8 e
return- g% T9 ?# y: V, A8 E2 Y% \4 G% d5 X6 {" M- v
#IfWinActive
+ A' E# n0 Q6 D6 h F+ s8 f& `: H ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 E+ `+ x: t/ P+ ?3 c2 F
; Note: expecting to be run when the active window is Explorer.1 l ]1 M# ^% \0 {1 ~6 j
;
$ a; b& s# K+ f5 i: I5 H5 X OpenCmdInCurrent()
6 ?/ D9 s: S! s. A0 u6 ?5 s& e {
% K3 C6 L# a1 K8 r3 F$ Q& b ; This is required to get the full path of the file from the address bar
7 @* c9 Q& j; Y2 ^+ P WinGetText, full_path, A6 E1 J6 }, A7 }; K# F* O
; Split on newline (`n)
2 I/ c b' k+ O6 o' j& W$ o StringSplit, word_array, full_path, `n
5 I3 O% [" C! X! S3 y; X ; Take the first element from the array
% u9 L& ^: ]) c* p: |/ W full_path = %word_array1%
5 t0 o! \ q# _4 m, [ B ; strip to bare address
H' O) |5 j; U full_path := RegExReplace(full_path, “地址: “, “”)! z( N" P: U9 d0 h' J/ b* n4 E2 [$ l; K
; Just in case – remove all carriage returns (`r). l: E7 P+ p$ p5 G+ I) M* m4 |" c
StringReplace, full_path, full_path, `r, , all6 _6 p; R( Y+ Z% i
IfInString full_path, \6 R2 {9 W9 t& B0 Z& q+ b
{! n3 \6 A5 }, ~8 f/ u) i) S8 q
Run, cmd /K cd /D “%full_path%”
. D3 m% v# o% {/ U( S7 } }
; a! {) p& H F- Y o else
7 X7 O: O2 K* l. q" B5 n9 Y {
! c. W3 J& O- Y: `/ N Run, cmd /K cd /D “C:\ ”# w0 j3 N8 \% Q9 g4 f6 z" m
}
& P( e# c5 ^; I& m5 @3 M" a* T }
. p) U! c7 n5 `* N0 L$ a4 y 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: @( Z* Z; b$ Q; [) |/ X 这段小代码肯能有两个你需要修改的地方
3 a/ X! W' n3 ]% V; V2 s& w/ |; i 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键& @8 b: J9 q/ F: v9 t8 Q( y
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 T1 A. z0 V1 D! |5 ^+ W- E. ?# R |