此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# B$ ?7 z: h$ V* F0 g
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。1 s$ V: u8 H) O/ Z( @' B; n
方式一:
7 V7 d4 x3 l7 p; K3 U' T' K8 b 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ H7 @6 B. m* ^2 k/ L$ R
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
6 m" Q8 T" b0 R# ?9 Y HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
8 O; J# e5 O O) {1 k5 i 方式二:" Q/ V4 [5 f3 R: z+ H* {
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:( O9 d' _/ _' d0 s
SetTitleMatchMode RegEx* |3 w* k+ @9 S) h7 z
return
/ B4 s# e0 Q( n' ?- d ; Stuff to do when Windows Explorer is open
5 j# l" y4 V3 O5 F ;- N0 |; y9 i. |; Y
#IfWinActive ahk_class ExploreWClass|CabinetWClass
% _! y4 L3 i0 O" m6 R ; open ‘cmd’ in the current directory
( {2 a+ E u' ?% j8 q ;
A' R/ O4 D# j( l4 n #c::2 L: t6 W* i! S: z& l1 _. Q; ^
OpenCmdInCurrent()
- S) {6 _: y* ~. w7 w return" B1 g0 K ~4 j# g, q# i
#IfWinActive
( S1 U/ u( l. ~, g$ L6 i; t5 I ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.% W# R+ Y: \8 t; [! @5 S
; Note: expecting to be run when the active window is Explorer.0 X' z9 |. Y, p) j# D( c- V2 ^
;
: r1 S! @4 H) e9 X3 K3 ^* p) I OpenCmdInCurrent()
5 B% U4 h) M2 I$ E/ s, b4 q {3 K, |% w% e# A; p, w2 y7 e: O
; This is required to get the full path of the file from the address bar
& ]- W P1 x; b6 \& H WinGetText, full_path, A
$ {# M" C# L8 J+ P8 F ; Split on newline (`n)+ A6 c$ ]: c7 F; b E; m
StringSplit, word_array, full_path, `n
6 o' i$ P3 N+ x8 @. h# w9 b2 O ; Take the first element from the array0 g; |0 ]5 X$ C; d! \% g
full_path = %word_array1%
8 Y5 s/ @" P4 U n/ d ; strip to bare address u6 j3 z% G5 X' i3 l
full_path := RegExReplace(full_path, “地址: “, “”)
* ]- X4 ?. O7 W8 q/ O0 M ; Just in case – remove all carriage returns (`r)
) }) `( n" Z+ z) l/ B2 d5 n; M8 K ?% m StringReplace, full_path, full_path, `r, , all( k4 l3 o' r- s
IfInString full_path, \
7 p$ A' o, o8 d7 x2 d {
. U7 Q. X2 s0 L8 X. N Run, cmd /K cd /D “%full_path%”
8 L7 l! c5 k- _$ }: ~9 v9 f }& I* V/ b. D* _
else) P5 r: Y1 C% s+ d- G$ h
{
% ]* x" f# J; [+ d Run, cmd /K cd /D “C:\ ”
5 L% R" v6 J5 v2 q! m' G }, T) e5 j2 c6 M3 r: y/ t( V
}
" z) `. T3 K7 ^, V2 Q( N 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。+ p! P- q% o2 \
这段小代码肯能有两个你需要修改的地方6 f- Z4 o- l5 b
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键/ c1 U+ [/ ~+ d2 P( H% C' T
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “ o1 d% C3 a4 A6 O9 L
|