此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 u' Z+ V& b" I3 t 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。9 @- i- x# _: c2 X
方式一:: K) t- w2 r& | `* K
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- }2 v7 T3 U3 p/ E7 U* n
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! a% p) T1 f# w- t4 T
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。7 T& s' ~6 X9 v. s
方式二:
9 i5 q# ?5 Q2 W6 d' _ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:, Y( W+ o7 L2 l. P
SetTitleMatchMode RegEx
( ?; k( i3 S3 q+ Q# E& q return
. k4 ]1 O3 i/ {; F) | ; Stuff to do when Windows Explorer is open
0 R( \8 o, z Y3 K/ M$ P+ I ;
4 _9 f( j! N7 T$ s: x #IfWinActive ahk_class ExploreWClass|CabinetWClass0 R6 h' f ?' x/ H
; open ‘cmd’ in the current directory
/ j5 C l+ R4 Y* y. q% ] ;$ b' h' Z! Q }- n$ G/ T7 I
#c::; j# \( Q! ^0 Z. {8 G% ?/ N
OpenCmdInCurrent(); G" H: v2 _: ~* G
return
& V" |% o( g- U# N; G5 x& u) f1 E #IfWinActive
0 N; l5 w& \+ _+ [1 G2 Y ; Opens the command shell ‘cmd’ in the directory browsed in Explorer." Q- g) K% l) h8 y8 I
; Note: expecting to be run when the active window is Explorer.
; i& E/ F& L$ e ;" x% q+ \5 R4 n4 g
OpenCmdInCurrent()
( s. h$ X2 e" W4 ^, B* D3 v {
- Z2 j; F# n# ]8 \ ; This is required to get the full path of the file from the address bar
; C7 @, i8 Z) e- w WinGetText, full_path, A
2 W) H0 V' q7 i ; Split on newline (`n)
3 o) g/ o5 b+ A! J! ^ StringSplit, word_array, full_path, `n1 a( A0 ~" H% T' P4 H. @
; Take the first element from the array
( g- t! V; r& n3 F% H full_path = %word_array1%
. a# f- {9 ~8 Q7 w' D6 |6 ~ ; strip to bare address4 f5 O! t5 I/ a
full_path := RegExReplace(full_path, “地址: “, “”)
/ Q) V+ q; H( p- n. E0 l ; Just in case – remove all carriage returns (`r)& A: O, E! D! c5 q+ J3 x6 _
StringReplace, full_path, full_path, `r, , all
. P) u$ }! t' \( H% a( e IfInString full_path, \1 i2 i; g( ? y1 b" c
{5 x1 S9 j1 A5 w/ A( u: r
Run, cmd /K cd /D “%full_path%”2 _" p p( ?* w/ U0 ]6 ]0 T# g
}
9 _# y9 r7 _8 G9 R" e, g( o else
6 `; N7 M: u5 _1 y* A" t' b9 a& @/ v {
, C2 r/ N6 x+ l Run, cmd /K cd /D “C:\ ”
* V' |6 _9 v8 p/ i' I% ~0 b }9 t& c4 F8 a: E) \, `1 I5 F
}( p" e( W) ~0 f p
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。9 ]4 w2 h- G5 t+ i; P4 k6 {
这段小代码肯能有两个你需要修改的地方
- n( p% K- a6 r 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键. n$ }5 J5 W; i
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 A. a! y3 Y# S5 H. c. y2 J |