此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) c. i: ~# t5 a- l
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。2 M( ^$ \" Q) K$ y1 ] f6 I* A9 Q
方式一:
5 A) u" O: i6 O; D3 {7 Q/ w 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,% f, f! [/ a* B
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 Q3 e7 `& C! ^5 m3 t' A
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ v3 F8 l8 } u/ f6 ?5 T
方式二:3 F! K% Y; h% h2 a$ V* B6 e
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
* H- k: m: b( b4 a( q- m: X* B( G SetTitleMatchMode RegEx
/ s! [% l& d# l* Y7 b; { return
* W9 } i& Y/ d% N s. k( r. T ; Stuff to do when Windows Explorer is open9 P9 D3 G; t( ]5 ]4 H$ q
;$ h. G* ^0 O6 K7 q2 C' z2 d
#IfWinActive ahk_class ExploreWClass|CabinetWClass( B& T* Q+ u7 }2 W2 R$ g+ M
; open ‘cmd’ in the current directory
* x2 G0 h3 n! t" Q4 i9 w. J/ \ ;) W" Q% e' ^8 M+ w6 A2 r
#c::& y) I+ m" C0 n0 U
OpenCmdInCurrent()% P, e {1 R' x2 m U5 _9 x
return" l! V8 x) ?. E- a, k' G
#IfWinActive
/ @- h0 r3 |" }% I6 J* H* U ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.$ Q( r9 `/ H/ s/ Q( ]
; Note: expecting to be run when the active window is Explorer.; ?: O" c1 y1 [/ v- ]
;7 g0 p$ ?: {: F4 [' w1 H8 W
OpenCmdInCurrent()
. i2 v4 m& Z% v) w d0 }; V) f& ? {5 c$ d. M# Q- e$ J: a6 E D
; This is required to get the full path of the file from the address bar. w! | t- D# u, Y- o; h
WinGetText, full_path, A k9 I! Q! h9 j8 b% X! q
; Split on newline (`n)
3 ?) }1 ], Q$ b3 l& E2 v( F StringSplit, word_array, full_path, `n
5 G! x2 A# i' v' ^! g; b8 ] ; Take the first element from the array
" F; I) h0 t$ c, W+ i1 M full_path = %word_array1%
9 ~1 K" K0 R% G ~9 L1 b1 o% ~5 R ; strip to bare address. p' W/ T# p2 i
full_path := RegExReplace(full_path, “地址: “, “”)7 |( P; P: ]! ^+ M2 E( D
; Just in case – remove all carriage returns (`r)" p K3 M: M5 t3 @( M; F' T$ w
StringReplace, full_path, full_path, `r, , all( `6 q0 l$ q( }7 k
IfInString full_path, \2 I4 n0 U8 P! z/ D s8 t
{/ l. [+ ?7 s! T b
Run, cmd /K cd /D “%full_path%”0 u# c* s( e$ _. b- P( U# t
}: \6 b& [5 C4 R% I' B$ `: t
else
9 Z0 h( ]) k2 v. t4 t9 f {
% ^: Q' Q6 P* Z( Z( b$ g Run, cmd /K cd /D “C:\ ”
( R& b" ^ s# e8 t, _( c# L }7 {6 W$ p3 C, S, z
}
! Y6 N3 ^) a Q5 s5 y0 O9 ~7 E 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。2 E4 {; \" j8 M
这段小代码肯能有两个你需要修改的地方
* Q3 D3 _# s }8 v 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键8 v1 b* g" Z& ^# l+ d& c. b- d) h
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ X1 D, N# d9 |" W6 {+ s( r! b
|