此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
. M& Q" ]3 ~ q4 q/ n6 u 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
) ^4 D! ^7 k2 l9 V; [. b4 t 方式一:
! ~/ @+ j8 l6 M6 ]% ~ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,2 L& c8 z& _+ [. \- P- k, X" k
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
, f5 c3 p( N5 d3 j4 Z HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
$ k: ]% N G, x& W1 z( e! U1 Q4 Q 方式二:
. z2 o/ M3 }" v 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:( S9 E8 n; M4 z& \ q& ?
SetTitleMatchMode RegEx, L9 \' A* g0 ^- X
return
& \, V" V5 a9 {2 ^ ; Stuff to do when Windows Explorer is open
U+ v9 l, L7 \2 V' W/ [ ;
( Y& d- [7 E; x% B" f1 I #IfWinActive ahk_class ExploreWClass|CabinetWClass( @" e6 P$ e: x+ `& h4 Q
; open ‘cmd’ in the current directory* q r- x! b9 V8 y
;
. w) i7 K5 Z; T Q. a4 ]! A; K #c::
' a2 J/ n4 a2 s6 T; l! U5 _ OpenCmdInCurrent()- r2 [- X' C' ]- R8 I U" H5 g; ^- ~
return
% A, t X* h$ J #IfWinActive. r0 r% n6 O$ ^
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.: O& w4 w" ^ w) R
; Note: expecting to be run when the active window is Explorer.
, t' d& ^, d# w2 _ ;
- b* p% N m: O& {$ z8 r' U8 p: q' w0 ? OpenCmdInCurrent()
& m, i- i7 t; Z# B {
$ Y; h% C8 d# S9 p. r4 q5 W ; This is required to get the full path of the file from the address bar0 {4 v0 f. [. ]+ Y" s, x9 }, ?
WinGetText, full_path, A
3 k) s! L) L- R9 t$ t; @9 x( [ ; Split on newline (`n)/ `8 z+ t$ `, C& f( Y0 S
StringSplit, word_array, full_path, `n
' Y/ z, A- G) a8 W9 O1 R0 h ; Take the first element from the array3 a4 L3 U% z7 E4 t
full_path = %word_array1%
$ S0 a& C! r$ Y! c. e ; strip to bare address
9 u- I4 w6 [+ i2 {6 q9 ` full_path := RegExReplace(full_path, “地址: “, “”)
1 Z% a+ W. G7 k1 \4 P, p1 g ; Just in case – remove all carriage returns (`r)
5 r; b8 M4 T4 @7 ~ StringReplace, full_path, full_path, `r, , all* {6 q9 J7 l0 m3 J3 H o$ q
IfInString full_path, \
( Z; Q; B, H* N; d {
" y. a) M, F# k Run, cmd /K cd /D “%full_path%”, l1 R4 F2 ?, t! j R
}7 w. k6 B, r( j) e
else+ {. i2 {7 v9 u; w: J
{
% e; Q. `* b5 u; p Run, cmd /K cd /D “C:\ ”3 ?2 h' V+ v; i+ i1 N
}7 a; D" X" [+ V! y/ ~
}5 n: R" D/ ^2 H: v! w
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。4 r* [# ~7 d. j. T2 ^
这段小代码肯能有两个你需要修改的地方
) `3 P: C ?; M# K" s2 _ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
8 `4 `) _# p a( M 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 o. y( M2 O. u2 P |