此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
) Y. k+ E8 K- T, C1 ]) A 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
" |: p# m. w/ @- N8 X; C. s8 c3 P 方式一:
+ o) H6 n& y% b: i% i 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
: j* s! c9 o, Y9 z" d. V 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和* r s V. x" H5 C) t# o
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" z' ?* D' W4 i. }- N2 B 方式二:; s5 `4 C4 O5 `7 U5 g. a8 z, \
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
% }1 ^7 }. z9 s+ q' J SetTitleMatchMode RegEx, w* p0 c2 V- b* G
return$ y1 t5 R6 r$ ]8 l; V7 s
; Stuff to do when Windows Explorer is open
2 W! P- V3 w3 v9 _! N ;
+ Q O( b+ g5 H% w7 Z #IfWinActive ahk_class ExploreWClass|CabinetWClass$ I# c9 l0 o" l7 x
; open ‘cmd’ in the current directory
8 M+ G$ F( d3 J' C% z& A& Y ;
9 c0 I) C* F! z6 |& B #c::
/ r# x; n6 f1 \7 `5 t( }, x OpenCmdInCurrent()
- S5 w1 s) K& ?8 y$ R7 c return5 u2 W+ G9 N7 _. g/ Z4 s% C/ L
#IfWinActive
8 h# C2 f, t4 l# X& `+ o9 i ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.6 b- ^) b1 D2 O0 @* u J/ c: @* H
; Note: expecting to be run when the active window is Explorer.8 P6 G: B+ X' G2 z2 f$ T1 n) V
;
' K3 k6 K& z- d8 p* _7 f- i& _ OpenCmdInCurrent()
. R0 |+ Z$ c+ W% j {3 s4 {. `5 Q9 ^) v* U2 Y
; This is required to get the full path of the file from the address bar+ ~% l( C+ q9 L/ A% r- I6 d4 l
WinGetText, full_path, A
3 V; Y- b. i- c+ ? ; Split on newline (`n)- E% J |/ }( c: X1 e& j
StringSplit, word_array, full_path, `n
E$ l* Y9 l' j7 u ; Take the first element from the array
; d$ A% _5 O; \" @/ \, p full_path = %word_array1%3 H5 [$ s* E3 T- Z3 ~
; strip to bare address
8 ]7 u# ^; B, {. z* z4 j full_path := RegExReplace(full_path, “地址: “, “”)
* _. p: P$ {. h, z ; Just in case – remove all carriage returns (`r)
$ C5 W; S1 @" X: y+ h. K) t* w0 a( h" z- S StringReplace, full_path, full_path, `r, , all# Z" A' R$ a& y& l V# c, J
IfInString full_path, \( W" i) c& g5 ]! H4 j
{
; z2 s& b3 v3 q: `+ T) m# Y9 J; c9 D/ L Run, cmd /K cd /D “%full_path%”* @- N! |9 X" ]5 w8 F( l' F
}3 T/ c* B0 M# Y
else, k1 Y, t% i0 h4 z3 Q- H7 L
{
, ~4 E9 w# M3 S: V5 l7 ` Run, cmd /K cd /D “C:\ ”8 g- g% N! t3 `" I7 J# I
}
8 s$ M* q. o* v1 ~ }
7 y0 T) d9 J _7 q& K# ^9 M 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
) ~0 W; R+ _" a# d/ K5 K 这段小代码肯能有两个你需要修改的地方
" ?# j! c" ^' w8 i5 Y3 n 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键" e# i( B$ |2 U, I3 {( k g- c
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “8 A# T' K6 }3 Q# b2 }" n
|