此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。2 p4 r/ [8 u3 }7 m1 Z" k; _" Y
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。, A F- X4 z2 O' H; Q! G
方式一:
* ?; s- K' T8 |+ l9 Z3 `% D! k 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,& |9 l# G n# [/ l; y' L# F
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 ]" a A$ Y* ^# P1 ^6 q; b1 H HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- s, H6 d. Y5 U( g7 h. U
方式二:
3 ?: j3 P1 T! b% H- a* x 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:" D" P W5 \5 G2 s+ Y' u) G, f
SetTitleMatchMode RegEx
* r! l/ s# E' I, |9 o& y return
4 @: [1 h: ], l4 E! f ; Stuff to do when Windows Explorer is open- r5 \# D& L) b
;
# J5 J) z/ J4 f5 z6 m$ g; V #IfWinActive ahk_class ExploreWClass|CabinetWClass |1 Z' X s! Q, J% _
; open ‘cmd’ in the current directory: n% u. `4 m5 V$ H( N( p
;
0 Y7 e+ Z6 ^7 ]: f2 O #c::
) q5 T$ Z3 \. I& n OpenCmdInCurrent()0 ~' |. _% }( o3 v/ @
return
6 A4 S3 |# W- n4 s: c #IfWinActive
* k, v5 u/ `5 S' Y7 v } ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' Z5 r. N% _# y v3 A' q ; Note: expecting to be run when the active window is Explorer.
& l% F: l( [4 M3 ]' G6 } ;
" t$ F, h* \ n- p/ d OpenCmdInCurrent()
' _2 H" O: ~$ B4 h {
- N0 O* {. E$ D- c ; This is required to get the full path of the file from the address bar
2 s: O( j1 g6 ?: K! |2 I8 O; I WinGetText, full_path, A( B2 A9 I; W0 @, i2 U0 M6 A
; Split on newline (`n)1 d9 B3 N+ A* v0 E) O: k
StringSplit, word_array, full_path, `n5 c" b" ]' t+ b, W, y& ~% h
; Take the first element from the array
$ P3 Z, C5 I( ]3 }1 j: g$ U full_path = %word_array1%2 p5 ^2 i8 h6 _5 Y u/ s
; strip to bare address
) v1 ]1 }8 K, J+ Y" I full_path := RegExReplace(full_path, “地址: “, “”)9 o+ I; I& W2 c2 z0 p1 i
; Just in case – remove all carriage returns (`r)
) p9 i: }- j. O! x" U7 S StringReplace, full_path, full_path, `r, , all+ D' }6 u! ]$ ]- _% g
IfInString full_path, \
0 y i+ w9 j" V# I. Q {, q$ U9 T* y* D6 y
Run, cmd /K cd /D “%full_path%”
, |/ F3 ~! v" `$ { } Q! e+ z6 U. C1 l2 Z
else8 Z4 m+ m* Q. Q) \& I& I/ ^
{1 J: u6 P. F# y0 [- V
Run, cmd /K cd /D “C:\ ”
0 t) d L7 m2 i8 D9 `' \0 V }( ]# w. D- K( B, W) \( e& b
}/ X6 j, @- L* h0 ]' H9 C
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 ~2 N! W0 Z# q+ u( S: a4 [: d
这段小代码肯能有两个你需要修改的地方. y' z) P% K$ g/ {2 E2 V% ?
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
5 M5 C" J' Y, x x t9 K0 b 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 @( s( [' S; M' U8 q0 x7 | |