此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
9 C$ r v g5 r- r 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
" z } W. H" o# @, f- e" p( @ 方式一:$ j% p( G6 }5 d
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
* c9 E4 k# _( q2 l0 x2 R9 e 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
% G8 Q8 r2 C" _( \9 Y$ { HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 ^! M7 j( N( D5 P8 g1 z 方式二:
2 I1 o# K1 H" t4 V$ c, p 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
& @" y5 E s" x& P# |( f+ `8 r9 r SetTitleMatchMode RegEx
9 ?( J6 ~* Q9 I6 i- \ return" R$ k2 S1 x4 y u
; Stuff to do when Windows Explorer is open7 b1 Z Y% {+ ?
;. G u9 o8 K, a
#IfWinActive ahk_class ExploreWClass|CabinetWClass
1 n+ \$ ~ l% H* j( a4 S ; open ‘cmd’ in the current directory
8 {0 {9 F/ ^' y ;4 N/ k9 \0 k2 B+ T, v: E) [
#c::
/ E6 p: ?! M }6 E5 d5 V8 j/ ^ OpenCmdInCurrent()
3 \7 O- K+ I) u) U$ X2 E9 G n. Z return+ f/ O! L& D6 U
#IfWinActive( k4 t3 ~" y4 q& S
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.: @9 {. K* F& x+ o
; Note: expecting to be run when the active window is Explorer.* J6 y! ]$ I/ w* z% U1 R$ K
;7 x0 M$ |6 ^) {; Y6 g n0 O6 H
OpenCmdInCurrent()- [: ^4 m5 l1 X' q |
{
% u# k& d: [, d& m9 G) k7 x$ r ; This is required to get the full path of the file from the address bar
; C1 q- M1 ^+ l WinGetText, full_path, A
$ S) }3 B9 P* e ; Split on newline (`n)
; m2 O6 Y6 `. s+ M- d' B, z StringSplit, word_array, full_path, `n. D% X, F y L4 J
; Take the first element from the array6 K" G+ b) k! g( ?
full_path = %word_array1%
. @9 U' J2 i! t3 c9 F# s+ ^ ; strip to bare address* `# m9 {* X$ b% L( e
full_path := RegExReplace(full_path, “地址: “, “”)4 Q' t0 x4 W& \5 @# r$ U
; Just in case – remove all carriage returns (`r). b+ d+ ?2 e% Y! m6 e
StringReplace, full_path, full_path, `r, , all5 `3 i/ @8 m6 S
IfInString full_path, \% X: q! a1 B+ x! w7 R& c3 I, x
{0 a7 O6 t; ?' A5 q) c3 z& A
Run, cmd /K cd /D “%full_path%”
) J+ T- v0 t. u5 Y1 q( b# H }# B/ t7 z6 s. @" @5 a+ j$ ~
else
$ u% T2 v3 O! f5 w7 j& j! T- e {
) k' [- q8 R$ H. I" w2 p: k Run, cmd /K cd /D “C:\ ”4 C i* C% p- E
}: H: z8 ~3 w5 V) }2 L( W
}
+ d9 G7 F! u) N& H$ L: h: G0 X 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 c1 [* b4 a7 Z4 J1 l 这段小代码肯能有两个你需要修改的地方
8 ]8 ?' L- Z- V2 V1 N" ?( p# T 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键5 m0 [9 |, y! N- M
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
: {& i( A, e6 L/ F7 N |