此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 ^+ K" _" J& E8 o9 f$ b2 T# a# t
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
* {( ?( J/ D" J 方式一:$ T6 k4 C7 G1 g. v
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,& Q7 e' r. T$ a8 s/ ]
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
?. h2 X7 g" t2 t HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 ^- g1 F6 j0 O5 Q7 r
方式二:6 G# l# D7 v1 v) P' y- o1 J
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 J# W& |8 | B5 ~ SetTitleMatchMode RegEx0 c' o! U: c+ r
return" g2 g3 _6 A B! z5 l: Y
; Stuff to do when Windows Explorer is open
" L# N( }! F& W( B. G* _, l. D ;
, V0 j$ f# ]3 [( V( Q6 k- F- u6 u5 j #IfWinActive ahk_class ExploreWClass|CabinetWClass8 V5 t" E3 G# D" a
; open ‘cmd’ in the current directory( m, L, x) c) o% o' ^
;
4 v1 U( c: L6 f' R7 j #c::6 P2 K# b" S# G% p5 c4 J9 K% v
OpenCmdInCurrent()) ^, e1 Z$ b* [$ ~% b
return
4 E: Q7 C) @0 P0 b #IfWinActive
, C) m' p% f3 ~ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer., s T* R' u" N
; Note: expecting to be run when the active window is Explorer.
4 y" O- Q R- n1 Z q ;
" x' u* m4 B5 Y% @ OpenCmdInCurrent()% n4 U& V0 l$ H0 u4 z
{
5 r' W& C6 r: O5 ]. g; G ; This is required to get the full path of the file from the address bar9 E/ F7 G) {. S* J M1 t
WinGetText, full_path, A/ R. m( K! A/ e7 {$ c- E
; Split on newline (`n)
! J2 O, Q. Q) {* o5 o `, k" e StringSplit, word_array, full_path, `n8 f. r# d- ]8 T, m
; Take the first element from the array @' H+ M; G9 j4 k0 Q, @
full_path = %word_array1%
' E. S3 {2 V* `' p ; strip to bare address* [+ A' c1 @3 U' j( d
full_path := RegExReplace(full_path, “地址: “, “”)
p: `: B6 U( Q8 C) j ; Just in case – remove all carriage returns (`r)$ X' g3 G; ~$ q# A, g- o
StringReplace, full_path, full_path, `r, , all6 l6 K$ |# ?( Q2 D/ z' A1 s
IfInString full_path, \
) R- T, x% t. d4 j {
7 L$ D" ^1 j0 N; l5 E8 { Run, cmd /K cd /D “%full_path%”9 o8 z- v0 {9 u: U y9 ?8 w
}
" o Y3 x! h3 ~/ x# ~ else
6 R& ]! E. M5 q/ I6 r! {( `5 K3 y6 Z {' i9 O' R! w- y' h- ~1 D
Run, cmd /K cd /D “C:\ ”: V. J1 ]+ S( J" j9 P
}9 @) ]. @, T- M4 l, S4 J; X" U- C
}
8 d h3 g9 L) D- u 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% }, W& H+ W& W) c/ |
这段小代码肯能有两个你需要修改的地方
, N+ d! W7 G5 r2 Z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键1 A' y: y2 b( }' J# E% E. x0 Z, D* H
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “9 d! @5 X4 g8 |' P: s! {
|