此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
$ ^" c1 F7 I/ A) {5 l" ]9 T 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。/ j5 L, R8 v E; @
方式一:0 o+ h- C+ q+ k3 ~, u1 z0 _3 K
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
( P' C9 Q* _( }. P9 G" G) B 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) C) _" q7 p0 j9 ^/ x0 u
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 K9 w# k! E$ R
方式二:
3 z3 b' `$ m- a; r 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
5 B8 ?+ V& w- _ d( G SetTitleMatchMode RegEx
j, a& h( _0 ^/ M I return
$ d! R1 Z; w" j; a: x# Z ; Stuff to do when Windows Explorer is open
/ d' J; e& G1 }9 f# U- x0 J ;: }0 ?6 r9 ?1 {* ^4 {' p* I
#IfWinActive ahk_class ExploreWClass|CabinetWClass2 G0 @7 T& Z, u8 h
; open ‘cmd’ in the current directory
/ N9 }5 l% H9 S4 V; L ;/ Z8 h, K6 \2 ^5 j( ~
#c::
7 `: s7 P3 [# ] OpenCmdInCurrent()
& [, x$ n* h6 ^7 t$ H return
T+ |: M( q$ E+ Y* ~ #IfWinActive; m e. O1 R/ w# d0 T
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# R% K; t; b5 Z, @3 D
; Note: expecting to be run when the active window is Explorer.
. n6 v. V; `- y ;
' C) T$ x! m g' D. ~( w! ]& b OpenCmdInCurrent()
& O5 h& r7 _0 q! T& n( l; u, F( ]: y- x- ] {
6 y" b6 W& V' v ; This is required to get the full path of the file from the address bar% l5 m6 e, E' J# s. D, X7 u- v
WinGetText, full_path, A$ Q5 q* A: K$ u3 X; r
; Split on newline (`n)
, |& U. x7 L | StringSplit, word_array, full_path, `n Y1 o$ X; j1 G C# r
; Take the first element from the array( {: q9 d) m" ~: ^3 {0 K7 y8 Z
full_path = %word_array1%
( Q! l: v& y% J' r ; strip to bare address
" P8 P X. C& \" ~6 i full_path := RegExReplace(full_path, “地址: “, “”)& H: S( @% o6 G
; Just in case – remove all carriage returns (`r)
8 H3 h8 K- Y+ { V$ @. V- W/ E: B( W StringReplace, full_path, full_path, `r, , all
( q! y+ V- ^: d% z7 c" R, A IfInString full_path, \
5 h5 i+ [$ d- }/ x {
$ J ~$ [) H$ u7 c1 o, ] Run, cmd /K cd /D “%full_path%”# |2 V8 j# F& }) T' g
}
, l, K; [# q3 P& C4 }/ l: J else
9 f, \+ e3 {; R {
# h' x( P' c/ W" c( y, z9 Y Run, cmd /K cd /D “C:\ ”
5 u, |' `- K1 q# V9 i& c }
V; Y2 P6 g ^: B4 X7 B8 A }
$ d* Z7 q" ]1 q8 S 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
/ X$ x* w1 P/ N. r& [( D 这段小代码肯能有两个你需要修改的地方 d+ A6 X7 }3 r4 j$ q# Y0 W
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键' A; G" G1 Q4 |
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “9 e% J; [! A: g
|