此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
& n* z* n; e: ~: |. q 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 |9 M! Y; v, {* i3 L0 A
方式一:. v; ~( X/ a/ g
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,6 M7 q2 e5 I! ?) x2 k* ~
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
7 {* b2 _0 y. a4 I( b9 E6 b, q HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
4 ]; s- c$ V- E# U0 | C0 P! _8 k* v 方式二:
; o; q/ h, v: w$ P 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:. U6 \) U5 I5 m( ]0 s9 a: f3 S3 Y
SetTitleMatchMode RegEx
6 s; @6 P9 o U0 i, c' d7 X% ^% d return; {# @ N+ }) s1 k; H
; Stuff to do when Windows Explorer is open
# v1 A" a/ {2 [. i, V ;" H: E: R0 w+ K7 X& y% y
#IfWinActive ahk_class ExploreWClass|CabinetWClass
& Q: }# L8 r% o1 B) f: ]7 y3 y ; open ‘cmd’ in the current directory
0 a( T+ n0 c) s1 z* X& ~ ;0 N {' x. J! E u2 q
#c::
0 w; T- p# m! C: N OpenCmdInCurrent()
. e. R- M3 g- l0 Q Z* V' p; b return
7 o. e9 i5 ?4 P" w #IfWinActive9 m: X1 n1 h* u9 s
; Opens the command shell ‘cmd’ in the directory browsed in Explorer." v. C% J5 {5 I0 ~! G
; Note: expecting to be run when the active window is Explorer.1 g" U$ j! h# o0 I+ G) [1 ^
;; z5 d0 m" e/ \ n7 H% c5 I! X2 H
OpenCmdInCurrent()' _- u1 |" x5 G, k6 Z- @
{
' t- N/ w2 j# q, \: O) i. ~, c ; This is required to get the full path of the file from the address bar, c. ?( m# b+ Z0 Y
WinGetText, full_path, A
# R6 P, r: ~5 E4 U- C; M( o ; Split on newline (`n)
$ ^& {9 k* Z8 x3 ~# a, b1 T StringSplit, word_array, full_path, `n# z" ^+ f1 v5 _
; Take the first element from the array
5 Y6 ~2 ~3 i) Q9 \) B& Z8 { full_path = %word_array1%! b' u1 b( ]+ }7 h% h
; strip to bare address
" [& w9 G- s# }9 x7 @# I full_path := RegExReplace(full_path, “地址: “, “”)% A2 ]- }6 R; y% q
; Just in case – remove all carriage returns (`r)
+ T: R f$ A; G7 } StringReplace, full_path, full_path, `r, , all
) I1 x! c4 i5 Z4 K IfInString full_path, \" p, I/ A( m' I0 [. U6 x
{% p- f* F1 w( p, p4 I
Run, cmd /K cd /D “%full_path%”. f/ f4 D9 T$ c5 q8 M
}$ R: F( P( B0 L5 c4 P; \, w. ~; o8 q
else
& e+ o% ~4 h0 d5 ?/ {6 w# V6 f2 `! n {2 d& U- F# R& C: R ]
Run, cmd /K cd /D “C:\ ”
: M0 N5 c1 A* R& G } g) L0 A0 ~7 R* V& n/ }7 ^
}! p7 y& g5 {& V4 J0 ]
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" k, Y8 @+ i5 E
这段小代码肯能有两个你需要修改的地方
9 c; B T% ?2 z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键5 o, ^6 _6 X( a/ |8 T! p/ S! e1 W
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
1 t7 x9 ~$ g: A' { |