此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
; L% n( f2 F6 U 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
5 m$ r6 Y0 p4 D1 E 方式一:
Y# z6 f( B# d; C0 \ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% R4 S2 `) S2 z2 q8 v 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 S) k& L/ M/ a. b2 o$ [5 X0 Z1 A8 z$ ^
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。$ ~8 K- Z$ [9 s
方式二:
# u( V" _) Y+ M" N3 V# w 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
& T' K2 e0 o! P7 {0 T3 ~' N3 u5 M SetTitleMatchMode RegEx
( M$ K! Z/ {- b' B return
( {% h2 ~8 s, N! Z ; Stuff to do when Windows Explorer is open( J' l% |4 H# n& z5 z
;( b2 D, u$ p* U1 k1 n/ m/ d
#IfWinActive ahk_class ExploreWClass|CabinetWClass% `" c* A! L1 H# H/ ~
; open ‘cmd’ in the current directory
2 X) @( b& V2 X. ` ;
+ E: {! h: P$ H1 J3 D, F& a) O #c::) y1 B0 r' _0 t9 s" U
OpenCmdInCurrent()2 {; k( B) K6 u9 I( T
return
$ b7 L+ e2 R( }+ r #IfWinActive. r- N( }: \5 C+ m) \
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
; d6 F4 h o7 a ; Note: expecting to be run when the active window is Explorer. o- G% b' R2 Q, |$ ]8 x; P
;0 E# ?* f B* c, S) m/ d" f2 s
OpenCmdInCurrent()$ w3 d1 j8 ]" k! ?8 X9 m s. Z
{) ]* U- F7 U5 q& `2 v9 Q
; This is required to get the full path of the file from the address bar7 N* W7 {( H+ }/ D* ?+ f. Z. f2 E
WinGetText, full_path, A" f b* l2 r& Z; f* n& n5 D; K) y
; Split on newline (`n)
" R4 f3 l: q9 m2 q% v+ d StringSplit, word_array, full_path, `n: z; w0 O `9 K, T
; Take the first element from the array
( Z% N9 F& l$ V4 n full_path = %word_array1%
f0 s0 {% k8 a7 h; N0 e3 V3 A ; strip to bare address2 s; y& u* i- v; j, ~2 }
full_path := RegExReplace(full_path, “地址: “, “”)) X8 o7 w0 c- D0 @$ n
; Just in case – remove all carriage returns (`r)* s* Y& z: | P4 h
StringReplace, full_path, full_path, `r, , all
! @) M& e: L2 t. q9 d( z IfInString full_path, \
( K9 }. c* ~9 f# r {
6 X4 g4 y+ i0 W! o Run, cmd /K cd /D “%full_path%”1 U$ f- q1 Q" O: \) O6 @" D
}6 X4 b2 w3 A- U H. N
else% m) ~ {; V+ G* p7 P+ D$ G
{
2 b- C' g4 ~. N! n. P; E5 e) t1 I Run, cmd /K cd /D “C:\ ” _; `5 R% T: g, Y9 B4 Q
}
; a# _) @3 y& q5 Z V9 p; R }
2 D* ?% S# W# P0 n1 i7 t 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
1 S l V3 B% s' V$ P5 g 这段小代码肯能有两个你需要修改的地方* B" W. Q: ~- U- C: t7 Q
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ v" G: @, p5 f 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
( [# g [; v, w |