此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。( U8 A, h3 j M, J8 E8 e
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。+ d4 Z K$ u$ G2 U+ }; g
方式一:
( a: m+ m/ Z' m/ V& y4 t' ` 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
" V; ~7 \3 K) h; { 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
4 } f' R8 B+ L3 m# {+ I4 R HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
- N8 Q- ? ?7 A; U# t, _- b) T 方式二:
0 i3 w8 J! x, Q7 m* ^! E 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
U) U" `3 P3 {4 p SetTitleMatchMode RegEx$ R" ~% C" ~6 T K
return
~2 n1 {0 m5 p* v1 {. I, j ; Stuff to do when Windows Explorer is open9 Q X& g, d5 Z9 Z& g1 g
;
" Y% g3 N0 {7 x* r, N* { #IfWinActive ahk_class ExploreWClass|CabinetWClass! X6 x- V/ ]8 R7 d9 Q6 A0 \
; open ‘cmd’ in the current directory
5 K9 i& h* d! h6 }" Y) D3 R# i' \$ \ ;/ ]% q* I8 F) |4 T i
#c::) N: B% r! g# ]6 t( p. R& X2 g
OpenCmdInCurrent()
! g, u' M# u. e1 ` return1 X* C4 b: g: {& r1 x E
#IfWinActive: q) l3 ?4 z6 G5 W5 g* ]8 M
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( o7 O& M& n8 s c$ K( z2 o. J ; Note: expecting to be run when the active window is Explorer.
( r1 t- V. n8 j/ Y+ i3 x ;
" B: O6 Q. Z& V% P OpenCmdInCurrent()9 I9 n$ e# V# G+ u, X
{
' J+ U) e! t, p# X! p1 E! r ; This is required to get the full path of the file from the address bar
; ]7 \9 H5 Q, M) W, _- @+ F1 J WinGetText, full_path, A
5 u H3 _2 @5 |' Y" }( [' f ; Split on newline (`n)/ X1 f$ G! ?0 ]# c# P/ J$ h
StringSplit, word_array, full_path, `n
: c6 T4 F; }& X( i6 v/ ]. Y; `! n8 p ; Take the first element from the array. z( ]" t7 B$ }" Q# F3 ^
full_path = %word_array1%& b( S7 W7 _% _+ h6 g+ B% I
; strip to bare address
! `. Z5 S5 J- @7 z full_path := RegExReplace(full_path, “地址: “, “”); p* h& b' f6 ?9 M3 a
; Just in case – remove all carriage returns (`r): @% T( A0 T a' \$ B5 B- Z5 H4 ^
StringReplace, full_path, full_path, `r, , all/ D: D5 @) X7 `0 n# j* S' Z
IfInString full_path, \
2 P* i# \) _( H- F. r {% N7 Q0 v: L+ `2 k( Z2 i
Run, cmd /K cd /D “%full_path%”3 ^' p% b+ z j0 V3 d" q
}& `' L7 f8 W7 k7 W* ~! p8 ]/ s5 O
else
+ R% z1 ^1 f, v. A' z {2 W( _6 v3 z# C% n8 V
Run, cmd /K cd /D “C:\ ”
- N3 O. z6 z" I, b, a }& z( |, A. \6 x, N8 M
}( @9 u5 d! g# \/ w- S8 r5 |* |& {
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。5 H3 K2 y) G4 I! L7 p9 S
这段小代码肯能有两个你需要修改的地方
4 |8 @# \4 Q2 w4 I& v( G. T5 N2 K 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键" P. i, W! }5 m& A
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
% Z* U3 C" d- m |