此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, e) s; B Y& J r) E$ d' ]5 t9 L
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
3 y1 D) e# f" P0 a 方式一:
6 }; h% Q0 I; f5 H7 M 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ n# r2 c/ Y* {. H: ]
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
* l+ `+ b, k5 F" R: ?: A HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
% q7 L; S1 s( @ 方式二:5 P! Z& j: o; {' \8 ]
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
% _0 f" a% N( D5 L: f8 n1 F6 | SetTitleMatchMode RegEx
; Y1 D; r8 [ O. Z2 I return# } X4 d& ?! r8 ^
; Stuff to do when Windows Explorer is open
# n5 `, K# |) f( P2 Y ;! L H5 L0 O8 A$ S4 Y6 F
#IfWinActive ahk_class ExploreWClass|CabinetWClass) Z1 U c. A9 C6 b D/ a: ~. ~9 A, L
; open ‘cmd’ in the current directory
/ @, |4 P2 r* O: I ;
3 U" f6 b* f+ s8 M3 c4 a( j #c::
( I# }3 y4 w9 Z OpenCmdInCurrent()
( O/ H) z5 c! w3 A7 I( Q6 ~ return7 K+ N& t/ b8 E! S/ o! d
#IfWinActive
: m; S0 q X$ e& u; ? ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
2 @# M! Z$ K- p ; Note: expecting to be run when the active window is Explorer.$ @; n. N+ U4 w/ k9 n! j
;* ^ u) {7 q' ?4 o* |; H
OpenCmdInCurrent()( c4 r% Z4 U, B& }# V9 h
{
( W! ]% Z( A1 y9 ]: S ; This is required to get the full path of the file from the address bar9 x8 P7 V! k" j7 S$ l8 i0 n4 ?* x# H
WinGetText, full_path, A
& z% n. P- t. y* I ; Split on newline (`n)
3 q% n& }3 x% Q2 G StringSplit, word_array, full_path, `n! C; v! z6 F5 o" K0 h* J3 P
; Take the first element from the array: I: G$ Z! M, [0 _! E
full_path = %word_array1%
, ?/ E$ c. X' W9 Q& O/ y9 {" s ; strip to bare address
6 k/ j$ P9 i5 Y/ j- v/ O2 \& S full_path := RegExReplace(full_path, “地址: “, “”)
% Z9 k2 Y D! N ; Just in case – remove all carriage returns (`r)
8 G- H& ]* W9 A7 N9 s1 q StringReplace, full_path, full_path, `r, , all
+ C3 e7 V0 I% @( w3 d IfInString full_path, \
0 o" Z' Z! S. I @- D. ~ {" P$ F v8 u/ u8 o
Run, cmd /K cd /D “%full_path%”
; A6 d- S/ p$ x/ o }
4 d- T X' Y3 z. [- s, L else* g8 k+ r) z% l* x
{
. W# v% |2 N" y3 M0 X0 S# n& b Run, cmd /K cd /D “C:\ ”
1 k5 B @5 a/ u* ? }
, g6 Z8 R- }6 @ }
$ ]3 b8 Y1 T& R; S 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。$ x+ a+ O3 N7 L; q
这段小代码肯能有两个你需要修改的地方* f% {' T1 O, F$ w- @
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键- }& r. }! P. f+ ]- _) d
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “ x7 @# o% `6 l/ d
|