此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
0 o1 j; s& ~/ H5 o1 W 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 \6 s; |# f# n4 ?% U6 s 方式一:; ^1 d8 r( B" V6 a$ ~* I h
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,7 \% H1 ^$ |( x$ l! i; t2 J
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
, M6 N; m* I: e Z9 T& T HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。2 }$ C4 [$ c& J+ w" g9 s
方式二:8 q8 u8 ] k! |7 K" W
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
4 S, s7 m7 S1 Q SetTitleMatchMode RegEx
0 q: X P( Q( ~0 x3 _7 B return5 c" z5 b; h$ C ^9 C
; Stuff to do when Windows Explorer is open0 ]" T9 N# Y; j: q) s# h) c* Y1 Y& E
;- D% P- M1 f5 _
#IfWinActive ahk_class ExploreWClass|CabinetWClass
5 [' v* {8 z @- L: w ; open ‘cmd’ in the current directory7 d0 S3 t s* l: ]* e8 x
;# V9 Q% v9 k8 J# ^$ J5 I, }
#c::
! I/ z! B; _% Z% V- E OpenCmdInCurrent()
" c$ E) k. h B! ~; ]% E return
& ?# |0 p" e, Y' d+ o% r #IfWinActive
: T+ d* O7 f. Q P) F0 X, A1 }4 [ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.& I8 p! k# ]7 s9 W/ ^
; Note: expecting to be run when the active window is Explorer.- }1 S, X: X' t% d' P9 t9 p
;8 |! X( `9 H2 m5 ~1 P: b
OpenCmdInCurrent()3 i1 p0 ^/ Z/ d: x' g
{
# h2 k& c' _5 | ; This is required to get the full path of the file from the address bar# Q2 ?- a9 M" e: b
WinGetText, full_path, A" g3 R9 I3 [% Z
; Split on newline (`n)7 Y0 F# y4 e3 m w, V7 h, P1 q: ]
StringSplit, word_array, full_path, `n& u z; Y: \6 h# l2 G- F
; Take the first element from the array
! V2 O7 F& i; U& R full_path = %word_array1%, T# v8 s9 ]4 Z5 e
; strip to bare address s+ l1 W' V N* U
full_path := RegExReplace(full_path, “地址: “, “”)
# a b" x; c0 |; w+ f5 H: Q ; Just in case – remove all carriage returns (`r)
$ z: k T3 L: K1 t: F; Y7 m StringReplace, full_path, full_path, `r, , all) F3 R! h- v. W1 V
IfInString full_path, \
+ [0 t, ?2 q% u* L6 l' M6 r {
2 l. j) e+ M9 X3 j" X& P4 w Run, cmd /K cd /D “%full_path%”& F' v2 p: N9 s/ z" f2 p: k
}; } {2 K: K/ \( p8 F% d! D# ]
else/ f: k3 i0 G5 T% E5 C, z
{- g) N1 \% U1 Z7 O: q
Run, cmd /K cd /D “C:\ ”
. D' G0 f, @- w n }
$ p& P9 D1 u" c }/ |6 _. A1 f# ~$ `6 C+ ?
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。7 ~ V7 O3 @) y& E5 v
这段小代码肯能有两个你需要修改的地方/ @: L3 x( @1 `- }" q
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
; A( c9 ?- M4 A! _ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ P: Y! m, h( _3 w, J |