此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。! [7 c. F( L5 p; Z
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 @7 `/ Y* p" _; c T 方式一:
1 T$ B0 [8 t/ ` F 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,3 d: G8 v" l0 w# e& V
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和9 d& a9 J- V# N7 b3 K; Q9 S
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
^% V# g7 J' w$ ~& }/ h) A 方式二:
: R$ Y0 C. b, v# G; M1 O 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
0 C! d, I1 E5 Y7 U SetTitleMatchMode RegEx7 P& B/ R ] P4 N: j& Q
return; ?" \9 G' N$ y( J6 j* [
; Stuff to do when Windows Explorer is open
) c2 ?8 W' E2 s* t3 F4 z ;
7 x( J U" T7 E% s( \4 e+ ~ #IfWinActive ahk_class ExploreWClass|CabinetWClass6 ]+ Z$ C+ k4 b4 M8 ^
; open ‘cmd’ in the current directory/ W- d4 ^% N2 j- g! q
;$ H- ]9 k7 X0 b
#c::
) N4 X: X4 Q! c5 |& H3 ?% H* b; f. Q OpenCmdInCurrent()
8 |5 n" t3 c% s7 ?" W return7 l- d+ i0 c3 M% q
#IfWinActive# N; n& B/ k* h. F9 ^
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
: j& e9 d. z' _5 U! g ; Note: expecting to be run when the active window is Explorer.# K. w5 l$ s3 X; t* p( b' C
;
3 G( y) n9 W s h5 y- L- N OpenCmdInCurrent()* L. c# k2 b P+ ]0 `! ]
{4 _" c' V" ?9 y6 {' J F9 \; D
; This is required to get the full path of the file from the address bar R) u6 V# W& v( @% `0 X* q
WinGetText, full_path, A
5 u( r9 m6 b& V" A3 Q* e ; Split on newline (`n)( D# k: O' w( o# b" ?0 Y& p
StringSplit, word_array, full_path, `n& Z* ?# m) H' l. }# E; X7 D8 \. O
; Take the first element from the array
4 D& h8 J1 l- H% S, L7 ?0 l" d! h full_path = %word_array1%, ^5 l+ R$ h/ {2 c6 O
; strip to bare address! e3 I) Z( d6 c) V
full_path := RegExReplace(full_path, “地址: “, “”)& _- b B5 C; z7 m$ Z0 I$ g5 r
; Just in case – remove all carriage returns (`r)* a0 X3 }5 g3 e* L/ }" X4 K
StringReplace, full_path, full_path, `r, , all4 A( J$ i( f0 p' k% r" N! v' w
IfInString full_path, \
) q6 Q6 X7 n. C0 H3 T {
9 z- m0 R9 ?7 K- B5 w0 K Run, cmd /K cd /D “%full_path%”
/ @* w8 l3 a+ m! \ }
& X" w# b6 Y4 d2 r V else
8 [% h% o$ z8 ]( ^4 k. L {
. |) ]+ L/ L9 `' v% [ Run, cmd /K cd /D “C:\ ”
) ]% X3 r1 m9 h& v' @ }
- r2 b- d" |' i }4 A5 C; ]! b- ]! g* e; ^2 r
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。# x& b6 N4 \; k1 ]: t6 f
这段小代码肯能有两个你需要修改的地方3 y! S" {/ l8 [& j3 F5 F7 S) d
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ x1 U& A {, f. Z6 D* K9 Z0 p9 [ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
( F- [- Q5 ~9 {! Q# j# N |