此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。9 a. P1 A9 |$ g4 }& A& w7 s
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。9 u, L/ i# U/ p; |
方式一:
. ^6 H: c$ ` Q6 c 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% ?7 e; v \+ V8 E0 J 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
0 ^8 A) L3 `& ?- v9 I4 ]% ]$ a. m8 v HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。$ e# M! d" P6 P4 v0 F1 l v0 O
方式二:
' J) T, N9 Y7 a q j8 ]8 J% L 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:' B6 O* e4 N9 s
SetTitleMatchMode RegEx
; C! e( z- N7 t% P f return$ L7 u1 u: l4 u9 ]6 J% X: N
; Stuff to do when Windows Explorer is open
, `0 Z6 ^ y2 O) {# |: R$ H" W4 } ;+ Z& u+ X" C" d- M; _) f
#IfWinActive ahk_class ExploreWClass|CabinetWClass
: K5 O7 X- d, Y8 T" y ; open ‘cmd’ in the current directory" v) k- f! z9 E/ i, v8 F' u- j
;6 k( J0 y2 f. s( X) }( W7 Z
#c::& e% i8 D, l, L1 I
OpenCmdInCurrent()* B; |7 t0 I, l- {+ R5 O
return, \1 L! c+ {% m- i- a4 }
#IfWinActive1 L- p( U- M6 e0 K9 y* ?
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
! t" P& S1 s) b5 w ; Note: expecting to be run when the active window is Explorer.
5 u8 c) r6 r# I% [! v; E' X ;
8 X( [& H) s+ N# j; _9 ? OpenCmdInCurrent()2 D! ^2 h& K2 t! i6 f
{% c. c) a2 y. q3 c" N
; This is required to get the full path of the file from the address bar- j7 ~( U3 Q- W0 H
WinGetText, full_path, A
3 x4 f& `4 M0 n7 i) _: `( T0 b ; Split on newline (`n)
7 x$ ]# N4 P% K L0 e9 M StringSplit, word_array, full_path, `n
; A4 M1 t. U: n: j& h ; Take the first element from the array
p4 s1 J1 \; C/ b; v7 ]; { full_path = %word_array1%
& Q7 i" e5 ^/ U/ q ; strip to bare address
6 B; Z) T h$ I full_path := RegExReplace(full_path, “地址: “, “”)
+ m7 b' \8 f$ l+ C! c ; Just in case – remove all carriage returns (`r)
: F4 Q( M/ ?( j# j6 k6 n5 f StringReplace, full_path, full_path, `r, , all
8 W( w. X/ P" a/ a$ n1 V$ O4 }" b IfInString full_path, \8 v B4 [% V6 y+ M1 r! Z
{8 Z b5 g( e7 e) a* C
Run, cmd /K cd /D “%full_path%”4 [5 J4 H* p7 A9 h& `
}9 O: v6 K3 E) C p
else. Z1 \# j; [9 q, T8 X4 z) A
{
# ?8 R3 v2 D* X* a: _ Run, cmd /K cd /D “C:\ ”
! W5 _5 z+ X2 |/ F }& N7 W4 p+ R4 d7 E0 V+ E
}* W/ J# Y7 o3 ~0 u X# K
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
/ B3 l5 a8 s0 h% b# {( o& \7 z 这段小代码肯能有两个你需要修改的地方. s$ R& a5 L9 h* R$ S2 e+ T
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
1 C. L0 w* p. V7 p& S' ^5 I$ W+ A9 v 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 z8 ^. @. ?8 q/ D |