此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。5 s. J u' D& y- \
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。* w" Y: D( ]/ a0 a. D- |3 |
方式一:
4 C# U/ ?! k8 J( x+ M6 b 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
A% b. G9 w) p, @' ?! [% A 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和- M) ^7 i" X( d4 |& P
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" V, [7 S. R) }% t6 @ 方式二:7 v9 n- P2 ]: B4 t0 R$ |
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:+ o2 M# d7 z1 D- m: t6 Q" |
SetTitleMatchMode RegEx
1 N& |* B- S4 G+ j. w& K return3 Y6 |7 C; \ Y6 U4 b4 t, a
; Stuff to do when Windows Explorer is open- i' d4 r9 B) J
;! {% u$ H/ @) }0 X
#IfWinActive ahk_class ExploreWClass|CabinetWClass
& @9 f* t# o( `# X. x8 V! x ; open ‘cmd’ in the current directory
" k' C/ Y% D1 n" w, e ;
3 ~; h4 e" y7 R) P: G #c::
$ P m5 V; M4 T+ m( p0 S OpenCmdInCurrent(); e6 R% K. H. d0 y4 z$ y
return
2 R% f O* Y$ m- N' f #IfWinActive
9 F' ~( i% n6 i) ^& c7 ~ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
; e4 X$ H9 l F) B; v ; Note: expecting to be run when the active window is Explorer.% X& K. N( q2 z4 d K
;
$ K J, Q: B; u7 ]2 g5 h. l! W OpenCmdInCurrent()
9 y! A, p. l2 q+ M {8 s! F- F2 A# k
; This is required to get the full path of the file from the address bar
p) O9 n6 N* I' S, K. N2 Q' x& \1 G WinGetText, full_path, A% y1 U+ S- f$ s& `& |
; Split on newline (`n)$ F4 j% g2 y+ `- T. ]. C! v! T/ N
StringSplit, word_array, full_path, `n% h2 \0 y0 Z6 T4 Q) s
; Take the first element from the array
/ o1 K9 S* Z" g W7 a full_path = %word_array1%
+ r6 g; y$ b7 B3 @ ; strip to bare address% s% L8 ~4 N7 V
full_path := RegExReplace(full_path, “地址: “, “”)
' \# j* R' l4 h- {- }. H7 ], T, Y# h ; Just in case – remove all carriage returns (`r)7 R7 |6 z; l( N+ A! ]5 d0 u7 Q$ }
StringReplace, full_path, full_path, `r, , all
, i) P8 Y& J: n9 W IfInString full_path, \
' ]1 V; l/ Q5 W! p, [ {7 l1 L# z4 O7 i; h
Run, cmd /K cd /D “%full_path%”
! a" c4 t: z! F8 M% o9 U }2 I" {; z5 I$ H$ j. ~: N5 g+ E+ n X( i
else
( N7 A2 H6 A2 v2 U! q {3 ]" e. C8 \: \# E' {
Run, cmd /K cd /D “C:\ ”
6 x* l5 K6 _1 t0 Y; h }
: F$ M4 N& R4 D }
: W. \4 F8 D- T+ l- @# G 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。1 ]2 L; G- p5 u
这段小代码肯能有两个你需要修改的地方
: f* l7 u/ v* }. B1 \% E( G' h& l 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
* C& @7 `1 ]% w 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “6 Z' d, _* \# m* I$ x
|