此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# _5 z- o, ~" b/ r
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
' p; ^1 U9 G4 A6 O 方式一:
; O& l3 Y5 l* R8 L 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
2 s2 n& k, c7 r& t, ^4 f0 j 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
+ v/ K) n1 M1 ? s8 U2 s$ |* ~8 d HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" K/ W1 }; \: j1 d4 K- M 方式二:
0 @' N4 s- @% B- n+ b1 ^2 } 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
" p6 N; c, T) `$ k* K. a SetTitleMatchMode RegEx% e; z. b# R- J. P6 M
return4 n! D2 Y5 ]) e2 W) Z* n
; Stuff to do when Windows Explorer is open
' n- V! q1 c6 x. |% [6 B$ k; Z ;
! {# Q6 h8 o% B3 G. T #IfWinActive ahk_class ExploreWClass|CabinetWClass
' ^; P6 g" k( J8 L- J3 A- H ; open ‘cmd’ in the current directory
' w' t8 y0 J1 {" q( P [2 L ;% o) k8 N% u7 I2 \" b; D; \4 ?$ `% F
#c::
+ ^* N8 B [$ g! V4 v$ I2 E OpenCmdInCurrent()/ P& A( A4 F/ c H0 Y( n
return
6 o f% d8 v: _1 u$ _ #IfWinActive2 U2 H- |9 i x! z2 ]9 t/ G
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
g5 {9 k4 x5 p' Z# c9 L6 m ; Note: expecting to be run when the active window is Explorer.
3 G! H# K+ i, y/ K ;/ D- k- W+ I9 K$ A; Z
OpenCmdInCurrent()) r6 U p4 w, Z- P
{7 d. S7 O: [! W5 `! }$ p0 Y" F
; This is required to get the full path of the file from the address bar
2 D$ q" [( U4 O; {) Q9 F+ ? WinGetText, full_path, A* t3 B: c6 Q: ~9 `& f
; Split on newline (`n)
4 s/ N( h# P) T$ L' V. @4 q9 F StringSplit, word_array, full_path, `n
# q$ Y7 I2 Q& Z ; Take the first element from the array& b% D5 l" d7 W6 b
full_path = %word_array1%
J+ u6 ^1 q9 B5 v3 V0 f* _( Q9 j# h ; strip to bare address
1 o9 B4 _5 y* Y, j5 [( p. h6 K full_path := RegExReplace(full_path, “地址: “, “”)
6 ^) E, s% t. @- w' v( P. z ; Just in case – remove all carriage returns (`r)
& W: h8 E2 @9 b, |) J( f StringReplace, full_path, full_path, `r, , all% x, `7 W2 @ Y2 d! x
IfInString full_path, \, B1 D& z8 Y# K! ]
{
& Y; h+ o; f& P* X. D. l' Z2 u1 x Run, cmd /K cd /D “%full_path%”0 g" n) U# ]! T! L
}3 j @5 U4 s% g
else
0 G2 C: z0 T' O9 k; h {8 ~0 S( t0 ?- `* u
Run, cmd /K cd /D “C:\ ”
3 ~8 E% \7 s- [7 _& Z }
( L; F! a% C+ j }$ h& j* h8 e: H$ v. H) G' X
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: i: ?" o% x. H; W$ Y! e- D 这段小代码肯能有两个你需要修改的地方) h+ q( E/ _; }, j" X3 c' w) X
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) }1 X" @/ M$ ?9 ?8 O- \& P
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
$ Y" l( A( S6 |# D, T7 Y |