此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。3 L$ V6 k* _* J$ y+ U) k$ w9 G+ p
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
+ h( G* c" a) E1 V0 i 方式一:
/ m# g8 p8 { v) z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
0 W* }7 b- ~! | 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
7 ]6 c2 R, }& Q6 X' V HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。! T& l4 C7 [$ Q
方式二:4 ?& t: P! O; N' `3 F9 S! q* ?
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
9 H" O) H. I9 u$ F0 z# F SetTitleMatchMode RegEx" k1 J3 j" y5 [7 I# p) ^3 p
return
8 \4 x. O' @1 K% U0 K1 R7 z! p ; Stuff to do when Windows Explorer is open
9 i* ^0 _9 ]1 {: A+ s, K: W8 H ;
' K( V3 F( v: } `, | #IfWinActive ahk_class ExploreWClass|CabinetWClass
. w1 L( j! e- \9 T( k. P9 Z ; open ‘cmd’ in the current directory& ^# _# j' E" M7 E6 i( [
;
p& `2 ]; x3 C& J2 ^ #c::% ]0 P3 m8 L4 q, n% a
OpenCmdInCurrent()
* P. A5 K& x$ i F: Y; y return
0 w h3 {) s; n" k0 v #IfWinActive
0 h, X$ q6 v; ]5 _ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
2 ~ N+ w8 u; y, y w$ P ; Note: expecting to be run when the active window is Explorer.
2 `( I; Y S) `7 n: U) g ;0 F. h9 w; n. ^
OpenCmdInCurrent()
( W) c. v9 n. Z2 u$ {2 ~, f5 Z {
C1 y. Z9 M1 i N+ G( t ; This is required to get the full path of the file from the address bar
7 G M4 z2 B( Z! z6 M+ p6 k WinGetText, full_path, A
7 x U& T, { \3 g$ W( {$ s, i7 k ; Split on newline (`n)
: e9 z# g' e. `& k4 }) L6 f StringSplit, word_array, full_path, `n. X" n+ e6 U$ {/ R% J' x* S; }
; Take the first element from the array a8 V) i. p7 ?4 v% b
full_path = %word_array1%
* U+ _: I9 |: }8 n" t1 {, j/ T% v ; strip to bare address
, B$ l5 t; E1 ?: Y% ]) q/ M$ t full_path := RegExReplace(full_path, “地址: “, “”)
( e0 @6 t, t0 D+ B; O* W u ; Just in case – remove all carriage returns (`r)
( B3 M! c/ U% C6 B6 p1 \( }3 i StringReplace, full_path, full_path, `r, , all
4 S4 n1 R5 e; v$ l/ @$ N0 @ IfInString full_path, \
) g$ R; `& F& D- U) z3 c+ t/ D {1 z3 N5 A4 ?6 E! Q7 t
Run, cmd /K cd /D “%full_path%”0 S2 G+ p* Z& G* P1 }
}' q' u7 u! E! E: w
else
' g u! V4 v+ L% k) l0 J {
: B* F& U8 K0 [: G2 H/ } Run, cmd /K cd /D “C:\ ”8 D4 T; s- S& @. l% |# B F, l
}3 f' i* o% \; N. p0 I6 W9 m& V
}. Z- f+ V# J3 g9 Y& `. N
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。/ e8 g Q, E4 |0 u1 K9 D4 U- E
这段小代码肯能有两个你需要修改的地方/ k* Q% \% B/ K+ [1 y
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( {9 {! L3 l. ^8 y- k( k) A 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “: u+ A) u$ X% {
|