此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
~1 s+ @8 J. w* J! b- e3 G 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% e8 H; H" N' `4 ?% g' V+ O
方式一:
, y! W* a; I( O 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
2 G. r/ S2 l8 C, } 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
( B8 N- v7 K" b+ H/ X HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。# ?5 j- v/ R* E
方式二:! R6 a4 \. d- Q0 O/ N# N
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ ?! f2 C! Y% z/ V2 \. P. ^; E SetTitleMatchMode RegEx- ~5 X- j+ h3 t" ?& P# ]
return
! T+ P F _7 w6 p0 @6 b. t ; Stuff to do when Windows Explorer is open3 o r+ f; f) m. _
;
* o! ]. Z8 p, v) w #IfWinActive ahk_class ExploreWClass|CabinetWClass \6 ?1 X5 Y$ v! E4 ~7 r! m
; open ‘cmd’ in the current directory
: N3 g: [8 L1 E, }! u ;: q; A }: J, F: W. x C6 y% [4 R! e
#c::
$ p }3 D5 \9 \3 p- V OpenCmdInCurrent()5 S' G m" c) w; F( u/ ]3 [
return
4 A7 a3 L) y+ s( h( r #IfWinActive5 t+ w# S5 S; n2 ^
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) X/ O, R" P* C b
; Note: expecting to be run when the active window is Explorer.
4 {7 A$ Z- M l2 O W ;+ C# ]1 x, G4 e1 ?+ v5 X* t, G
OpenCmdInCurrent(). s8 \! O: u! y4 V
{. f" ?( H$ l& y! x% g# h
; This is required to get the full path of the file from the address bar
( T! N7 Z/ A" t; A8 v$ }) |. |7 ~5 ~ WinGetText, full_path, A
8 \1 S- g; L- |! J+ q- } ; Split on newline (`n), L3 s6 g& @ Q; h7 q! x
StringSplit, word_array, full_path, `n
V6 {+ u( e( q! W& i/ C: D' t ; Take the first element from the array. [9 \+ o* `2 I- D4 w$ C8 c
full_path = %word_array1%. n% r; o, _' S$ `" Y. T' o
; strip to bare address
?8 B2 z% N( W0 i# z full_path := RegExReplace(full_path, “地址: “, “”)1 Y3 Y8 \/ J8 |
; Just in case – remove all carriage returns (`r)
4 f! T/ W: C: X: u0 Y% l7 V StringReplace, full_path, full_path, `r, , all& Y+ M* E7 ^+ i3 G1 r
IfInString full_path, \9 e5 M" s) d) \1 V4 ^, r1 ~
{
: K! R# \' H G6 n9 S$ U Run, cmd /K cd /D “%full_path%”
4 Q4 ~) B/ U# G M4 x: X }
- x6 D& r5 ?# ~0 }$ ^7 \% C else) P) O2 I0 L; c% I' [- Z) Z9 {
{. @0 F8 ]+ }6 m
Run, cmd /K cd /D “C:\ ”
5 x c$ P: w2 z1 H0 {& K; g }8 y$ B# R5 l6 O& U4 O7 N1 |: ~
}
6 ]+ F. x9 X" Z 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! ~( W. |8 s3 A6 d4 E/ z( x9 R
这段小代码肯能有两个你需要修改的地方
5 ?' Y* V# s, x7 q 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( q* R; \% @1 Z. K/ L* p; d$ N. @ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) E0 i- K) c8 ~9 J! l |