此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
1 [6 |$ U- ^ |2 E5 r7 {3 @- c8 A 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 W1 F6 T1 x3 W# w$ p, m 方式一:
' w8 y1 P, K8 O0 [ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,$ h: _4 H) e& }9 ~
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! c2 d0 a# l- Y8 K3 ~
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
. T. L. m& `0 L" r5 k m4 t 方式二:/ p% P5 v, n+ a5 e4 Y6 m
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 k$ q( q7 u2 }' x- x' t
SetTitleMatchMode RegEx
: Q" X% D' N" o/ X% S( K" v return
1 \- [+ {3 C* Z- u0 E+ w ; Stuff to do when Windows Explorer is open+ M* H# ?# \7 T" K3 A# E' g% u$ r
;
4 q" L! o% H1 i# M% _7 v9 M #IfWinActive ahk_class ExploreWClass|CabinetWClass( e5 z8 H) U8 o& d
; open ‘cmd’ in the current directory# v) q! `( U: c: C! s/ q7 n; @0 j$ s8 a
;" [0 h& W8 g& ~+ B
#c::. _! Q; a: r- x/ R$ O; u" r& i
OpenCmdInCurrent()
" K/ ~ f+ V. ^. h# C; m; ]9 k return J; N j% U8 e6 k8 _! T/ ?2 \6 s, v
#IfWinActive7 M9 H5 i$ {" A+ k" t# } U
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
8 e! w. R1 u/ Q5 O+ u4 P/ b ; Note: expecting to be run when the active window is Explorer.
; n/ F- u3 h' ] ;! v# p- P# A% ~& O
OpenCmdInCurrent()
' q# Y8 j% }2 u& \ {
8 \# X- K" E# x( }) A ; This is required to get the full path of the file from the address bar
* g6 h x& K7 k# _4 S WinGetText, full_path, A
. a7 ?* F7 M' F1 Z4 o. q ; Split on newline (`n)
- b+ r* c# s3 e1 w. W StringSplit, word_array, full_path, `n
* w. A, T* M( v ; Take the first element from the array) L7 F h$ u" [4 H0 C3 N( G
full_path = %word_array1%: v$ O$ a8 V$ E: y+ c9 U, f3 i
; strip to bare address
) X. |0 T- A8 K* Y% ]0 L& X full_path := RegExReplace(full_path, “地址: “, “”)
U( x4 h. n6 u+ p% Y: x0 d- e- B0 W2 h ; Just in case – remove all carriage returns (`r)
0 O, h S; ] t3 z: ~* ] StringReplace, full_path, full_path, `r, , all
@; r* z9 k( E+ e! }( Y: y/ ~ IfInString full_path, \- z! ~, |$ w+ }6 z% q
{
3 r( w( K7 c* p2 S3 s4 N( F: m Run, cmd /K cd /D “%full_path%”
8 H% z" p* J/ {+ \ }2 X6 Y; b: L! f9 I0 R
else- v! h8 G+ f& ~/ q3 H: c/ L
{+ q, Y2 I5 k9 y* t% V8 e4 {
Run, cmd /K cd /D “C:\ ”
" }. G- K/ }* R4 C* s8 A }) w( D4 z) M* f e
}& C0 @/ ~/ L& }( Q
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
0 B& F3 `, _7 M5 n2 \ y 这段小代码肯能有两个你需要修改的地方
* h% z4 f9 r; u9 j0 \! g9 r- p 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
r2 B) v: y+ R- K4 F% y7 o 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “) p0 T# }7 |$ @6 E
|