此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 ~. j; V4 `& j1 |/ }
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
! @# K/ ~% o) E% {) g* k- Q* y, S 方式一:
" f8 ^7 i1 V% J& C$ G* S. s5 Q 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,' ^1 G" d( s* _
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
. F/ S5 |1 c: T% `; w HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
& o% E- j& h6 {% Y( H/ p0 w 方式二:
* ~+ K0 j4 ? k9 B+ E 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
6 _9 w5 L3 K G$ E SetTitleMatchMode RegEx
" j+ E. L+ g7 _% u, L return# c* r8 Z) m! w4 k% `# w
; Stuff to do when Windows Explorer is open
1 H. x% M/ |) r* R0 H; y( q* y ;
R8 C' N! F3 r8 e2 x/ p; C #IfWinActive ahk_class ExploreWClass|CabinetWClass4 a3 c, `5 m5 C& T/ z
; open ‘cmd’ in the current directory
8 O: r- j2 R9 _" k2 N3 D- D. ^/ a ;
) g) b1 @; [- e' ] #c::5 X) N7 i3 G% w! ]! a4 i% ^5 w( v
OpenCmdInCurrent()* H& W& v9 _% U" `. @4 s$ c
return
& {& A* _: F0 O0 @ #IfWinActive5 V: B& V5 w- w2 h8 k9 o% B
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
5 _7 u( P# j# n/ h: Y4 L# @6 e6 T' B ; Note: expecting to be run when the active window is Explorer.
6 `' j# J/ L8 v! K7 S3 R ;
8 `% y4 s M; M% Y# c# c OpenCmdInCurrent()6 {4 |- L1 \0 y/ d$ [1 H
{+ T/ F' ~% _/ c9 I* i% x. m& @8 a( ]9 ?
; This is required to get the full path of the file from the address bar
% f, W1 j; N) E# ]2 Y3 q WinGetText, full_path, A# U* }/ H: y+ Z0 y
; Split on newline (`n)
! g5 C) Z! R. @' L- d4 J6 }" `; R StringSplit, word_array, full_path, `n
) Y/ t* y5 o2 {7 I% f2 c8 D ; Take the first element from the array
( M* O- J b) [. {) R+ h+ \ full_path = %word_array1%
& G/ A' G* O/ Z+ ? ; strip to bare address
8 s2 z( ]3 T5 ~( u full_path := RegExReplace(full_path, “地址: “, “”)5 n/ |; q8 Z2 A1 X3 L% b
; Just in case – remove all carriage returns (`r)
6 s4 } ^' x; g4 c/ v- i; T/ ]" ~, M: k' N StringReplace, full_path, full_path, `r, , all$ e @8 Y z' r4 F. u' _
IfInString full_path, \
$ V+ z; Q4 e3 M8 Q/ K {
7 D( Y$ _( q% K7 K Run, cmd /K cd /D “%full_path%”$ s5 F# V* d w+ K
}
7 ]: v/ W( R4 I- \# } else$ d* `3 R% E9 M
{. m7 b5 c" ]2 \
Run, cmd /K cd /D “C:\ ”; B& S# @6 @. H4 U* o3 F7 b$ r/ r
}* r/ K4 z. d5 r. j; l+ f( H
}
& T5 w6 R! d% O' |8 h 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。3 h3 P4 {# z; V
这段小代码肯能有两个你需要修改的地方
# H# V) _! {* I" z3 v; p 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键' }0 ?0 Q% X, L/ T/ r
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
; w" x: A( S' k2 E |