此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。2 o. U* t4 c) t7 g. R. |/ H/ [
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
% i$ _- _* d, O" a9 A( B8 q 方式一:
- Y2 X# i' }$ P7 `' v 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
/ |, m) m) G- Q0 K& x 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) P! ~2 R$ A/ F: a
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
]$ j) E$ f: ^2 A3 p 方式二:2 H @7 T" {9 D& u# s, P
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:& Z" t9 X, U1 _( }9 l* y
SetTitleMatchMode RegEx+ j* G; I+ z5 Q3 [$ e7 j+ e
return
( W% l" i6 f( g6 G ; Stuff to do when Windows Explorer is open6 u' e" Y% @% F( t5 u
;
. u1 q) ?& S0 w$ Q8 _$ E( a #IfWinActive ahk_class ExploreWClass|CabinetWClass2 K% l b% a, L
; open ‘cmd’ in the current directory5 g: O, n: P8 }5 ^+ [1 w
;
& }. Y8 M4 b" \1 Z! [ z #c::4 C: `0 R8 h/ \$ q6 [* V6 b9 I
OpenCmdInCurrent()
6 S7 b+ b- N+ B: v4 X$ X5 q$ E return/ h6 L o" E J8 v& U+ m! U) L& ~
#IfWinActive: p N0 p% K+ o0 T6 p2 u+ e
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
3 [5 q/ j- z- V$ C0 S: Y; n( ~1 \ ; Note: expecting to be run when the active window is Explorer.3 W& q1 M- p/ t
;
5 ^6 ]/ S* a, x* d. ?: ~3 C9 Q* p OpenCmdInCurrent()
- ~- O% i! x9 t# W/ x {
6 u4 j9 t- \) _6 @ ; This is required to get the full path of the file from the address bar
5 ^, T1 A9 s! x X0 P4 l WinGetText, full_path, A
' Y7 ^7 r6 k* u! l" R5 @" c ; Split on newline (`n). a a3 ] s4 d* s1 l* |
StringSplit, word_array, full_path, `n
3 S0 @9 g, k; T4 Z ; Take the first element from the array2 r& S5 |* e. \3 v
full_path = %word_array1%
; c# @$ e% N& Z8 ^; n8 [; J' A ; strip to bare address
2 x# i7 T1 l: Q1 `, K full_path := RegExReplace(full_path, “地址: “, “”)
3 B/ X" P" |0 A4 j3 S) a ; Just in case – remove all carriage returns (`r)3 {5 i+ d% a0 Y( h7 o+ C; z, b2 }
StringReplace, full_path, full_path, `r, , all# A6 v, M+ T! X" u3 p, f( z# M, Z: x
IfInString full_path, \
3 T- G" r. U: M& ?+ c+ @9 D c {1 ~: P9 Y2 f/ ^* P! ]; }% h
Run, cmd /K cd /D “%full_path%”6 r- h' I% Y0 B7 F! e3 @) S
}
5 x0 b9 h' j" b" A- A else% k9 R8 r1 y; f0 _+ r* Y- R
{$ }& [" F# \, Q9 s# h6 S5 _
Run, cmd /K cd /D “C:\ ”
% j; n3 [* S9 t: u' `2 n }( m$ [0 c8 Q' \) e0 `
}
0 v1 A V+ l0 |4 K# E& n9 ~ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
$ S) @# |) x' B9 O/ ~! a 这段小代码肯能有两个你需要修改的地方: x% E1 A w* ^, U7 Y0 @: S' I. T4 M! o
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键3 f5 m2 [. ]2 f+ o1 D0 _
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “8 Z% u8 d5 L- j8 Y5 \
|