此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
. T! D( L% g. v9 x4 I 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
( }0 T( c( ~5 p T6 @0 e# b0 Q c 方式一:
/ A5 o: D% I* m' a9 B5 R5 D 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,! a% h2 N8 g( o4 P
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和% [9 t' J- c" N
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。' L6 L3 u X0 X% D- g$ N6 t" ?/ K- [
方式二:
' b# n/ e# T5 f3 L7 q) M 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:$ |8 \& f6 G; d# p- p! C! G" C/ x
SetTitleMatchMode RegEx$ I a2 V. \. S( Y: w8 y3 Q
return
+ x# ~% A; U& l9 S' ? ; Stuff to do when Windows Explorer is open+ M3 Y# N9 y/ J8 g
;' y; m; `* z9 o# T; a4 F8 `
#IfWinActive ahk_class ExploreWClass|CabinetWClass
" w% e- L$ ^2 g# I1 p% T ; open ‘cmd’ in the current directory/ K2 O1 ?7 R" N1 e; ^3 x
;
. t. }4 Q& J6 |+ }& [. U #c::
/ }5 x! b+ L! ~# r% u1 U OpenCmdInCurrent()
2 p3 A& [( _# y/ o$ t return' M2 Z# b, h8 U6 A4 U6 Z
#IfWinActive) L. I$ V7 z3 | L) ]" J' x
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.: u0 Z, s- a' E- N1 n
; Note: expecting to be run when the active window is Explorer.
* t7 B' @$ P, v8 H, r2 z9 [ ;
6 i8 ^) @$ f. O) f5 ^3 W9 m5 ^; q OpenCmdInCurrent()
8 B4 |2 N) u' g! L% W. C {$ O s% K# ~; N
; This is required to get the full path of the file from the address bar% p' ?9 O8 N$ J2 Z, r
WinGetText, full_path, A0 n6 V" z+ I! }2 |8 @# g3 P
; Split on newline (`n)# y2 s, p) u0 s5 I E% J8 W
StringSplit, word_array, full_path, `n
/ X( e6 `; k) m$ k* @ ; Take the first element from the array( q* |% J% [$ V: f/ @% I I
full_path = %word_array1%
1 B1 }2 k0 N' {% Y$ b ; strip to bare address$ _. l. P" L/ C! o# a
full_path := RegExReplace(full_path, “地址: “, “”)
9 @! S* r" m; z9 v+ n8 I2 | ; Just in case – remove all carriage returns (`r)3 Z5 |/ y# y: p' ^
StringReplace, full_path, full_path, `r, , all: |/ t3 S& L! e1 V" u8 H
IfInString full_path, \
. j* ?, M0 y! @* K2 p- t0 e3 f8 t4 X {' \- K& u- c4 E4 i, Y
Run, cmd /K cd /D “%full_path%”' J" l8 y7 E$ w) f7 R
}
9 E% v4 M3 q7 F8 c e else
) R1 \9 K9 i9 G# V3 r {
8 d% @, z& R3 e+ | Run, cmd /K cd /D “C:\ ”0 D' k6 }: ?& Y# B4 ?
}6 q) b5 ?. K9 w/ t" w
}( }- S ?0 M" ~' D, {" p) W7 _
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。/ |5 q' F; C: C1 y
这段小代码肯能有两个你需要修改的地方, @, M3 d0 U; H Z9 N8 I& _
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
7 B. r. C" N4 W$ ~, i 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
! I3 K: K1 ]5 w% O& E7 a |