此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
( p$ f8 x5 `* X- P% T 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。# S8 Q- ~1 W- `. g" n* o; G5 H
方式一:5 L% k2 t8 S+ b+ k; z; o
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ `4 n6 M x2 t" z
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和& d* ]2 o3 K5 F: \' @( T
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
6 Y: u( s3 q- e) B, b ` 方式二:2 O( R5 j+ D* w) J9 D0 v& }
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:2 g& Y0 I6 N8 X1 x
SetTitleMatchMode RegEx! n& k4 _& v" h1 _, @
return
! C6 j& b/ a2 S' ^ ; Stuff to do when Windows Explorer is open! V5 C k5 R/ `1 J: `$ [4 H T
;
. ~+ c; q% Y, u) }$ @% J8 a/ R #IfWinActive ahk_class ExploreWClass|CabinetWClass7 j7 }5 ~0 G; @9 C% _
; open ‘cmd’ in the current directory! X1 \9 b2 y: g" C% B7 w
;
7 N5 b5 [1 s; N* M, J #c::4 o' m% f: o7 I& K8 w* W7 R, ^
OpenCmdInCurrent()- g7 h- M6 z+ d( c$ _8 g9 o4 u- R
return. m: x8 b- ?! S- p' `( I$ j
#IfWinActive) T% Q4 {8 a( t
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
6 z; b Q& u* I1 |8 d: S ; Note: expecting to be run when the active window is Explorer.
% @, m8 }. p8 h+ K. P ;
% `) V$ T% u% H/ B* T. i OpenCmdInCurrent()
; f! W2 z0 i4 {/ ~ x3 k% F {
6 I; l3 R: a0 r+ H1 m: g ; This is required to get the full path of the file from the address bar
/ {% N/ P" D0 U+ L" T" ^ WinGetText, full_path, A
+ p2 m- z0 T) D; B- P ; Split on newline (`n)4 \: G! q4 T! Q- B: U
StringSplit, word_array, full_path, `n' J& o' X2 H1 G. M( P2 H7 h* f" D
; Take the first element from the array" {; B. e0 s" B8 `0 ]. n& C6 b
full_path = %word_array1%1 F2 p+ Z; _ w+ D2 s
; strip to bare address
0 p( \8 `0 h' s( c- p full_path := RegExReplace(full_path, “地址: “, “”)
. F9 Q6 R9 x0 z) d- l. f ; Just in case – remove all carriage returns (`r)
3 O+ u" g- J- U' s5 |! H- Y, Y StringReplace, full_path, full_path, `r, , all! g8 J Z) p; }& h" `
IfInString full_path, \
& Q& R4 I6 K* r {; C% }7 h* a( B( S# A8 S
Run, cmd /K cd /D “%full_path%”
: j6 s5 Y9 L$ q- q }
( m5 O/ N& Y, ]6 K, @+ p! S else/ g" A; a7 v4 ^$ G$ r- R& b9 C* Y
{
7 R3 j1 W$ p3 {* ~+ `9 D# ~/ @, @9 H Run, cmd /K cd /D “C:\ ”: l7 f0 P6 U! B
}
6 J' V* u9 p% z- {* I6 _6 J }
: r3 u& @ ~2 j' A 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- i/ J4 F& R7 Y Y2 O! G 这段小代码肯能有两个你需要修改的地方
' g) P. D$ n" t7 R% {3 y5 _2 M 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键; _8 R" p! P& O7 N
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “( \6 ?/ [) ?2 P. q0 W4 W
|