此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
7 b0 h) r# C" ], Z3 T& [ Q, C 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 q* ]/ }" N6 I* O3 V- w
方式一:
8 F- q2 K$ J$ }& K6 e 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
# B9 N% u, }3 A/ L% {) h3 k J! B 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
) {+ x3 l9 v1 l' u% S HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
0 t1 z+ V: K; e 方式二:
2 p( Q4 j* c2 ~. _2 o% K) p. N 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:2 S4 t" O5 o, M g7 {7 u
SetTitleMatchMode RegEx
) K" t( g# A! K7 J4 M+ r5 ?& x return7 N/ ^7 y' K3 R
; Stuff to do when Windows Explorer is open
& o9 H, q+ @( r4 |8 L ;+ D+ J: C- L5 s0 y5 O
#IfWinActive ahk_class ExploreWClass|CabinetWClass
2 k+ M6 ^3 l. ^7 S7 ^4 l, U ; open ‘cmd’ in the current directory
1 j! v; o# B/ M$ F ;; n4 @0 j9 |/ g
#c::# R' P% f4 d5 P1 n
OpenCmdInCurrent(); v2 _. \. u0 A9 d# O9 m
return9 M7 I$ O' t9 P9 p7 F9 B' U
#IfWinActive- T, m+ _- W% P) m4 k( h& g& \# E
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.6 Q h0 i% \% {7 B0 |& p
; Note: expecting to be run when the active window is Explorer.( b+ S0 Q/ |+ f3 M0 C8 o
;+ }' ]$ h. c! o. R* @! \
OpenCmdInCurrent()
; V: H) }1 e6 a$ r {: H4 u% ?9 @9 J' R% b. X; N2 c
; This is required to get the full path of the file from the address bar3 L% a7 |7 j0 o7 }) f
WinGetText, full_path, A# Z! X5 C2 [7 A/ L. l; O
; Split on newline (`n)4 V) u5 A- n7 y% W/ O1 D
StringSplit, word_array, full_path, `n; M) u1 }# e9 Y/ ~# c& h8 E
; Take the first element from the array: U( q6 l5 V: Z J1 Q* V! {
full_path = %word_array1%" u6 C! D. Q8 d5 _6 x' n
; strip to bare address' t. K$ K8 ?' e
full_path := RegExReplace(full_path, “地址: “, “”)
( S: I, z9 `# |2 P. ~) ?& ] ; Just in case – remove all carriage returns (`r)+ u' |4 b5 K6 _
StringReplace, full_path, full_path, `r, , all) O6 N* u% H2 _5 I2 X
IfInString full_path, \- s" Q# I, R/ \$ c" i/ q: L
{
7 \6 j4 t% d7 |" Q Run, cmd /K cd /D “%full_path%”0 u8 l. X# U5 g5 R h; i
}3 @- d7 A1 D6 K- E9 r
else
5 r" g% U& l; g% p9 \6 E3 ~ {
1 x" s& t& O/ c. A, T/ B f6 `3 Q Run, cmd /K cd /D “C:\ ”4 U/ y) E6 ^' ^% n+ s7 W v$ |3 I
}, j4 C" Z& D/ d) a( `# m% f: i
}7 R& _' w- z* E/ T9 D3 [+ B# n
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。/ g! ~3 J! r$ m( X
这段小代码肯能有两个你需要修改的地方
" x4 x; R3 `, N0 {5 B0 B1 g" w 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
6 n8 p& b2 F" }/ B2 A9 V# D 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “& V7 |$ j# Z+ K% y( F( g4 j
|