此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。. ]: i* \, ?5 V6 f8 P
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 k9 W1 D- a& b, q8 y/ u5 { a
方式一:2 s$ `. F+ s+ B" K7 s7 S- j
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
5 O! H; }- C! h# O 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和( H7 c. p% O6 y& x4 l# f+ L$ H
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
- x- q& l' N; Z6 a" } 方式二:
N0 L) E9 F1 P+ ?4 b, N# h/ }- d 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 v4 K) G9 x7 C8 p- I) Y
SetTitleMatchMode RegEx
& X, h; c4 i: Z return
+ D+ ^3 x0 M4 S% I ; Stuff to do when Windows Explorer is open4 s5 V2 @: v- m( r
;+ Q' M5 {1 k* J; j
#IfWinActive ahk_class ExploreWClass|CabinetWClass) L5 h, k3 B4 e+ N
; open ‘cmd’ in the current directory
4 o* y! T: e- p; E6 h$ ?1 }, [ ;
. G$ r' v M; Y8 G+ }: Z' ]( _ #c::% Q% J) W/ N# G+ L
OpenCmdInCurrent()
1 p- R& ^+ R+ {# v! w9 V7 M return1 E; f& c1 v% n, p; @# p
#IfWinActive
0 L; J& ]/ k7 p) u ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 [. C" O0 R' d" I6 D6 ]4 O ; Note: expecting to be run when the active window is Explorer.
: m+ F! D+ V. E% l I7 C ;
1 ^5 f1 `8 Q2 j) n OpenCmdInCurrent()
" r$ @4 v. T$ r {& [7 m- T* j' W5 H! n+ `; ^4 F" y) H: N
; This is required to get the full path of the file from the address bar
2 Z) [! _& @$ S- p. X2 a: { WinGetText, full_path, A: F; g4 Y8 _7 q* D4 U- X6 M
; Split on newline (`n)
/ o! Z: y: c* t" u7 t StringSplit, word_array, full_path, `n% {& ^2 q- r9 E; o5 D( R
; Take the first element from the array& _: Y$ N2 C) |7 V' q
full_path = %word_array1%9 I; r# w9 I' b* @, W1 D5 ^
; strip to bare address& v; v( r2 R$ R! Z' i7 i
full_path := RegExReplace(full_path, “地址: “, “”)
& Q( B7 V+ C$ }& Q3 B9 v) z" j! E ; Just in case – remove all carriage returns (`r)
: p. {1 N; U5 Y y( @ StringReplace, full_path, full_path, `r, , all
' l. [, j/ C' o- h @ IfInString full_path, \! i5 `. O6 U% D3 |- w
{9 f9 \6 r. v) r
Run, cmd /K cd /D “%full_path%”; V3 D9 }; l) m# }. B( j
}
6 ]' y6 N& a$ D I else% | t( @# e2 @
{6 o9 H, C4 ?* O/ V+ W% v8 A7 y2 s
Run, cmd /K cd /D “C:\ ”
" C: E1 b% _) v# v+ Q) p }
0 Q: w2 S7 n8 C. r! G1 g" X }4 a/ i( N) o7 G! L% y, e) f1 t
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。4 z" T& J _* S5 q9 @
这段小代码肯能有两个你需要修改的地方
( D" o, N# c0 _+ }6 g$ c 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键0 @& J3 K4 l" d* C; l$ V! `
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ F: L" c: S! U8 N! Y: H; T |