此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 w& ?% @: j- J" z 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 u0 ~/ e) L3 r) X& I& j
方式一:
% J2 y9 W! _7 g& Q8 a$ n, M 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,6 }% D$ ?# l5 `; E
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
! x: b3 \# u2 T4 U' m1 Y HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
4 v8 V. A, s& u* I/ c 方式二:4 a, m, E! d5 V& p" p) r& C
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
4 W) ?; Z/ f4 c* g8 N1 X! V SetTitleMatchMode RegEx7 h$ p5 o6 o3 f* y9 ]) D
return9 d7 s* w# R; U" Q
; Stuff to do when Windows Explorer is open
! k% r% z2 H' J- F$ Q ;# K% Y6 I& z' z0 Y& r, L v
#IfWinActive ahk_class ExploreWClass|CabinetWClass
8 I+ ^* N7 b2 t ; open ‘cmd’ in the current directory+ g# c* U7 \* w
;
' ~( Q' X$ J3 E( `% ]* f #c::0 V9 m" }, q8 p# |2 @& g7 u
OpenCmdInCurrent()0 x; Q# F2 }4 l- [
return
0 k. P# w4 _: E #IfWinActive& ] ]; F- r& @
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.. r! P" o% x& p. J
; Note: expecting to be run when the active window is Explorer.
6 k [( @4 z6 d6 e7 W ;
1 @% }8 \. E5 V* B: `! v- b7 O+ D OpenCmdInCurrent()
$ E; Y0 M; e" q, C" ] {
6 d) G, {3 I; p+ p ; This is required to get the full path of the file from the address bar
# h8 c% Q# E2 m4 ^% R J/ w1 G WinGetText, full_path, A0 k% g& \3 ~* Q( ^ b, V
; Split on newline (`n). u0 m* L) I5 b; J) t
StringSplit, word_array, full_path, `n9 ]8 X3 b6 o* L8 V3 {
; Take the first element from the array
5 o# ]* [" t- `7 U7 G: C6 C3 n full_path = %word_array1% b- O4 T h6 Y6 c
; strip to bare address, ]7 @6 n) i8 u) D& G8 D' K3 q, E& N
full_path := RegExReplace(full_path, “地址: “, “”)
1 B C- K: h" c; j ; Just in case – remove all carriage returns (`r)4 _! ~3 E: `. t. x9 w
StringReplace, full_path, full_path, `r, , all+ n T% `: z9 O, B
IfInString full_path, \
7 F$ ^( V+ g( ]9 h$ }- R1 b {. y+ R/ }$ z8 T- Z- Y
Run, cmd /K cd /D “%full_path%”
6 @$ c. [4 q1 C( j+ u6 _( P- A }
* v* L, i# c! @- \: S ? m else1 z8 m1 e6 Y1 o0 D, Z" ]
{. M0 p* v5 k$ X( C4 m2 j
Run, cmd /K cd /D “C:\ ”
* y/ y Y8 H) _0 p) i }+ c& k; `2 c3 h- @9 _* B
}1 l% v6 Y; G* q! a: N$ M
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
$ v! Q! d5 e7 d* I 这段小代码肯能有两个你需要修改的地方
+ R. s d8 y+ ~: e- t7 Y# Z% ], c 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
/ `' A1 B3 ^3 T& W8 U 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
; N3 c7 q- H1 E |