此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 w1 C$ {! q8 F* s' k$ L 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
" [ N, \0 W# b) b 方式一:$ r5 S8 _- [; R
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
! s6 V7 t, Y% x: X; _6 a9 c# l 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和( E+ A( ~ E! l' a; s/ S
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。, k8 Z. C! C, T- U
方式二:# h6 a0 V1 d5 i
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
! ~3 {; ^% F7 r9 {+ B& ? SetTitleMatchMode RegEx3 |! K) \$ g7 k- V& D
return& S' h* W* F, ]* U
; Stuff to do when Windows Explorer is open
$ T3 a s/ x' u1 I- l' T! J# ^8 R ;
+ y) n* G+ D0 Z #IfWinActive ahk_class ExploreWClass|CabinetWClass
f) f. U" Z( K- W/ h/ M: `4 L- R ; open ‘cmd’ in the current directory
. J* ]- i' a# h3 ^* o4 s ;
4 y4 @! h+ W, N! G7 R6 v #c::/ k2 W% {* {! [3 s% s
OpenCmdInCurrent() t( t& M% @/ X$ R+ f: i
return
, [0 B- Y% E/ `# R- ` #IfWinActive
' u5 s" n0 D# Q( R6 B ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.. T- f; l" v% Z
; Note: expecting to be run when the active window is Explorer.* D8 r Q; h+ j' H& K5 e9 |! s2 L
;5 |- _% J+ T$ @7 K @3 j% R2 C
OpenCmdInCurrent()
/ ~1 [! W) }; F% b, H- B: F2 w {1 @; x' f; H& ], {# Q( z$ A$ i
; This is required to get the full path of the file from the address bar
7 t- V5 x7 u- W& x' M. D. Z WinGetText, full_path, A q* N9 i7 F3 f- }7 t
; Split on newline (`n)
) ]. \. ^3 h6 p StringSplit, word_array, full_path, `n9 l' U9 [/ A" h. L
; Take the first element from the array
7 {3 c/ y* b0 D2 W6 M' e4 q- a0 w7 K full_path = %word_array1%# V! D$ Y, i4 |& U2 d
; strip to bare address
; H( F& P5 o( z4 \ full_path := RegExReplace(full_path, “地址: “, “”)% q! g$ J( D, h( t3 p$ R
; Just in case – remove all carriage returns (`r)( N, }2 H" t4 u5 a# z3 ?
StringReplace, full_path, full_path, `r, , all: y2 A! N/ _ s/ E( U+ D {0 p, _& D
IfInString full_path, \
2 x. U7 }1 l/ X9 ]. L( G$ y3 g {* U: {% P& m. v8 P
Run, cmd /K cd /D “%full_path%”
$ A. I" s) ?" j/ z }8 U, p# f5 j( @8 `! o+ b" F
else
0 j% z1 s& `( e# e7 Z {
$ S' s3 S4 A1 V- W( d& _ Run, cmd /K cd /D “C:\ ”
; O' Y1 e7 t+ b' G }6 s4 _# f$ ^: }; s8 i* `
}+ M; ]; p; N" d4 Z
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。8 j; Y3 p: z/ K8 ?+ J# S' h( q( F9 v
这段小代码肯能有两个你需要修改的地方* V/ k. J: g) ~7 G( p+ V3 b
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' _& Q" v) d: x1 }- H. z4 Z6 p& r 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ l. O0 G& Z& ~2 O2 h. R |