此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。. L1 ]0 U0 y, h" Q" {( N) a" d
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 v9 N+ Q! a1 O/ I 方式一:( T1 `' F. _' p2 X$ m$ P
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
/ Z. t, k; r; {1 S3 @ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和# u$ `4 t$ d1 n8 M! ]8 F8 ]
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ X+ c& k# ^) t5 {- }5 G
方式二:: ], W* A' l/ F5 B
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:* _" X$ Q+ k5 }! |4 ~
SetTitleMatchMode RegEx
8 A! @/ b8 o- p, ~" z5 e& l1 r: l return1 a) U' R5 |4 S7 q
; Stuff to do when Windows Explorer is open) x6 G) C* W! v
;/ X8 `6 S& K- i$ x+ z* L
#IfWinActive ahk_class ExploreWClass|CabinetWClass
6 h! w; f- z+ {8 L2 ?6 S ; open ‘cmd’ in the current directory
3 `/ H9 W2 Y7 @! D P ;7 e* a) p+ j3 Y% b& w P7 }
#c::9 D# J( e+ G6 [, d
OpenCmdInCurrent()4 t( K& R, E: L5 R# M0 o/ G
return: L8 d# B- I0 t" ]' H2 N4 r- I
#IfWinActive& i$ j# \( I2 C. I* {% ?# ]
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
+ a/ M- f0 M9 r- V! K) t ; Note: expecting to be run when the active window is Explorer., n' H7 A1 l$ Y3 F
;
" v( g+ S; l$ d p OpenCmdInCurrent()
2 o! N' Q7 n* ~. `& f9 ^' g1 p9 ` {
5 L# W3 }. n6 |6 [ ; This is required to get the full path of the file from the address bar
8 K) L T9 u# {9 d: }6 ~ WinGetText, full_path, A
1 D x0 F- u" Z& R ; Split on newline (`n); ]( b" r) d+ [! W1 l- ?
StringSplit, word_array, full_path, `n
+ Q" N% j; {# S0 I1 ]# w& l" ^$ t* d ; Take the first element from the array. A/ D. I1 ]6 p5 a$ L! W* P# e
full_path = %word_array1%
* }1 x) o- |! Q; E0 B1 M2 H1 A ; strip to bare address
. w4 z* k8 P! d5 L% @9 L, C full_path := RegExReplace(full_path, “地址: “, “”)8 Z( _' y* l. _7 c
; Just in case – remove all carriage returns (`r)
! o0 h. \5 L4 O StringReplace, full_path, full_path, `r, , all" b M+ r5 S; b! Q) H$ N# a# M
IfInString full_path, \
( v2 y. g8 S5 t8 n9 k7 f4 U {. i. W/ M8 L3 `3 L
Run, cmd /K cd /D “%full_path%”
! x" w7 b; `0 e( R2 X% X) ?% g }, [3 L. v: M" `7 d
else+ L# T- L, G1 W+ D, Q
{5 e2 H- K# U: D( v. ^ k+ G$ s
Run, cmd /K cd /D “C:\ ”
2 ~; w+ ~7 s, m# ?' { }: b1 Z& k7 |/ w5 A9 T+ }' F
}* f5 N& S7 K4 m! A$ G
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。 h+ Q4 ^. G0 z4 S8 ]
这段小代码肯能有两个你需要修改的地方0 ?% X5 p# h% n( t& V: D& B: `" ]* E
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
h/ ^$ ]8 U, t9 f 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
6 R- i$ s6 Z( L# H |