此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
. ?6 q+ v2 d$ _ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。. Z% @0 U: ?/ w4 p9 W" H: L! ]
方式一:
) j) z1 }/ x. B 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
: |: v$ {% E/ M4 K 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' V, i: S! C. `3 |9 P/ ?0 _
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 ^- H2 X2 A$ V) }/ q) K9 f 方式二:
% M6 E! R' P% P2 \' P, k 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
. [& Q) l0 o4 i5 }- v SetTitleMatchMode RegEx' A4 q8 E5 p5 \- e6 j9 f
return2 W5 K: {( j- y. u
; Stuff to do when Windows Explorer is open0 f6 z$ }: I. B) I
;
8 ~+ j& Y* L- t, o #IfWinActive ahk_class ExploreWClass|CabinetWClass/ K1 z. M' ^7 n0 L
; open ‘cmd’ in the current directory1 w6 i2 X, U1 O6 y% u; f4 Y! \0 }
;3 m6 A' P, l) r% u
#c::/ ?. n/ ^3 X( Y% i2 L
OpenCmdInCurrent()
* V# B6 W: `' H. q7 O* R# g return
3 T% U% x$ |9 o7 ?: M #IfWinActive8 ~+ C( }$ R0 U
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.1 R c o% l3 h1 W/ G/ d0 W$ D
; Note: expecting to be run when the active window is Explorer.
: g. B+ b, \7 A0 R* O ]* b ;
1 q# @' ~ T9 n# Y; t( J' s OpenCmdInCurrent()
- a/ ~0 Q. e# j( u3 K6 g& r2 D {2 F2 N, j& Q4 j/ P ]4 D. D" y
; This is required to get the full path of the file from the address bar8 A4 V Q( s; t2 C5 [* W5 _# ]9 ^
WinGetText, full_path, A( c) f1 Z$ S- D* z% `
; Split on newline (`n)# t. H9 L/ `* ^" k! [/ I% t
StringSplit, word_array, full_path, `n
9 U% R, a) J8 s2 s5 G1 s ; Take the first element from the array9 k4 [4 Z d# z
full_path = %word_array1%9 @8 ]2 @( ?$ g' i) C* r" O
; strip to bare address
7 |# Y5 ]8 v5 K* h. Y0 ^ full_path := RegExReplace(full_path, “地址: “, “”)
2 H) E. g$ j8 j3 a0 p ; Just in case – remove all carriage returns (`r)
( u) ~. i# O8 R# w StringReplace, full_path, full_path, `r, , all" K- `4 Z" M) v& I ]/ g( K
IfInString full_path, \
. L) r( d; d0 T2 j {
. y: X+ k/ R% M3 B+ p$ I) P+ _ Run, cmd /K cd /D “%full_path%”
: Y! V j+ S0 e1 j' w- u2 f }
5 i7 r' |" e% h! ^% ^6 `/ E" v& K' | else( u# O7 o. ~" p" @
{
. r4 n& \9 G! H# n0 x, e% c Run, cmd /K cd /D “C:\ ”; B* o% I7 v: a
}
: n, R# g! M" U, P: L% T" [( h }
3 x2 c0 }( c4 |! p0 e6 b) y+ B 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
. k! {! b, W( B: l9 b 这段小代码肯能有两个你需要修改的地方
- W# b% ~- r' S% C- r( r# w2 W 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 J- H& f- Y8 Y
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 D) |5 P' E" k- `7 E! R4 S
|