此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。( i$ Q, q8 t5 ~- s
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。4 F* n" a v0 K7 X9 H# S
方式一: S1 ~; z8 T# H5 S
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,# `0 Y7 s; m9 r. Y
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
: u& {* G# C4 e HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 p8 f8 h2 x8 ^. u2 {& N1 \. P
方式二:+ Z* J0 e: X! d, v
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:8 P! `6 W: u3 O6 m
SetTitleMatchMode RegEx
, c* U+ X G. V: W return, G# ^' r0 X+ j h
; Stuff to do when Windows Explorer is open+ ]7 s w6 z0 @" P( j6 [% l( }, Y* Y
;8 M/ }7 n r" }: [) N' |
#IfWinActive ahk_class ExploreWClass|CabinetWClass
$ _" ~. s; W1 X- y! L- M- m* d% X ; open ‘cmd’ in the current directory3 m2 z& I/ M3 J( v4 }; K
;
6 _: M. y& x2 f+ D) G. _6 \0 T #c::
+ u( |5 `: L- a0 v% m+ k8 t$ t. J OpenCmdInCurrent()
( L% L: d/ U' a5 H2 ~" o return& a/ Y, B, m, Q3 I M9 E
#IfWinActive0 m( M4 P. A! Q' K& k9 k- V
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.' a5 [4 A8 p* q; \
; Note: expecting to be run when the active window is Explorer.9 H7 n- j$ W7 c/ K/ u- a/ c
;
' f3 n5 }2 T% A7 E OpenCmdInCurrent()
l, e' Z, s+ \/ R- G- R$ d {
8 S+ e; x5 z. T9 \% [- _ ; This is required to get the full path of the file from the address bar6 d) L2 u- q/ `5 y% d: {6 D0 `; [
WinGetText, full_path, A/ g) A5 n1 S! d& b5 [- g$ W' ?& d
; Split on newline (`n)/ d& m' S6 j* C: Z
StringSplit, word_array, full_path, `n
1 w8 I8 B u# c) r) I/ x6 E ; Take the first element from the array* J1 L) j1 N# n7 o0 [3 N l% g
full_path = %word_array1%! T' c) D* K) _% `- |
; strip to bare address
1 z4 m( G/ y$ q( S( o. A" E; c full_path := RegExReplace(full_path, “地址: “, “”)
" _; q: h0 [1 z! d ; Just in case – remove all carriage returns (`r)5 o& H1 w8 e! v6 L( k
StringReplace, full_path, full_path, `r, , all0 A) g) ?9 t0 F# z1 ^
IfInString full_path, \, s0 }4 s0 h: {
{
" y6 K4 U: I& _% l6 I$ i Run, cmd /K cd /D “%full_path%”
$ J# Y0 t( `$ K& p% d- g }
# J4 s. C4 g4 g/ w, d$ l8 p else
' h% Y% r2 l% i# J, }; g1 B {
5 ]$ f$ V; a! F1 i$ h1 j6 X3 ] Run, cmd /K cd /D “C:\ ”6 P0 O" n, K$ v8 v- ^, W' C- I- w
}
2 m# B- [# l% u! N+ c }$ a2 S3 r9 n& j# i: P8 C
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。3 Z( r" [; O( V/ W
这段小代码肯能有两个你需要修改的地方& @: D# |0 N4 E4 Z7 X6 U# p
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键/ T$ w) P' y m8 [$ b
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “1 D+ x: @' t* G$ }: s
|