此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 O. l! T: H. X% @! j
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, \) F5 H3 w; c 方式一:! M6 d8 W% F, y" {7 {
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- D8 P# n( k! _' s! W) f
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 S! I0 }. [0 X" ^ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。. w1 X7 c" r/ x% J
方式二:) ]+ _$ R: d8 q. W2 a2 T2 q
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:, r! ]& Y! ]& j
SetTitleMatchMode RegEx
) f: D( A- s3 m) O. X1 { return; `6 A( ]( v- E3 V( n
; Stuff to do when Windows Explorer is open3 A) a! q0 B1 c
;
$ \& ]% O, \% e& O3 J _8 D+ v #IfWinActive ahk_class ExploreWClass|CabinetWClass
6 |# j/ G$ C) r, S0 {9 F ; open ‘cmd’ in the current directory
, a( l0 Q" l/ v8 I! Z6 B8 w ;
- ]; ]9 J; r, k- D #c::
: Q, `. q! C* I! O OpenCmdInCurrent()
, q9 ?8 G1 O' ` return8 X6 c& ], Z6 t9 T3 t
#IfWinActive
9 y Y4 e! I: J+ q ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.- [, g" k8 n- y
; Note: expecting to be run when the active window is Explorer.
- j' Q' C2 C3 V( I ;
! q9 u' u# X6 |; W8 j OpenCmdInCurrent(); R5 L% q' ?& D
{
; e0 e7 W' B& T2 Y4 O1 I ; This is required to get the full path of the file from the address bar
( b2 z( Y* F% g4 n WinGetText, full_path, A$ R4 e" b5 P1 V5 u
; Split on newline (`n)
- H1 O; j9 Z# n; d" O7 W; ^$ T StringSplit, word_array, full_path, `n
3 ?7 ?1 R) e r N/ _9 S! g ; Take the first element from the array7 l7 g) P: `6 R# F) u" f6 F0 q
full_path = %word_array1%
/ M- L5 ^' M3 C/ E, ?; L ; strip to bare address
$ I9 R! }& l. s% m( }1 [ full_path := RegExReplace(full_path, “地址: “, “”)3 J1 B0 D0 S! {
; Just in case – remove all carriage returns (`r)
0 T9 H$ L" A5 \ StringReplace, full_path, full_path, `r, , all( L0 M+ f5 b$ b8 o2 H$ A& N( ?
IfInString full_path, \
9 t7 G8 u# |5 L" ? {* \) |( Y0 X* p
Run, cmd /K cd /D “%full_path%”, t O9 w! H, T% I8 Q: ~
}) p9 O6 E y; |0 S$ h
else4 ^$ c ~1 a6 \, k* n! C
{3 x1 c( Z; `4 E. q% E$ i
Run, cmd /K cd /D “C:\ ”
& S& m9 W( t6 ^5 g }6 ?# p d) Z8 j- ?
}
q4 f) N8 {2 G& R 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
7 S, N) g4 r: s2 ~6 D 这段小代码肯能有两个你需要修改的地方/ s* Y6 u- R! u
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键; E( m0 x/ ?6 y; b+ H
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
1 y$ k5 U# u9 W, P3 @1 R- x% {, F" i |