此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。9 r3 K; N/ ~2 `- m+ o* B
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, g" }6 K0 T/ Y2 l$ r" v 方式一:. X8 G0 p2 ?: ~0 f- B
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 N4 @" }$ E& x9 ]! {3 N 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
) a f$ ]8 {9 u! y HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
7 C6 [/ Z5 q W: P' w0 Q! f 方式二:8 G% o8 }& W5 g s. v: I
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# U3 d! c) W/ i* n) m% s SetTitleMatchMode RegEx
& t6 O2 q7 z8 T. b3 s return' S2 x& x* z, O% F) ?
; Stuff to do when Windows Explorer is open- l4 m; I" \$ G! J6 i9 q) Z
;3 ?' t# F. O: F+ e( g5 Y% |' O6 h
#IfWinActive ahk_class ExploreWClass|CabinetWClass
8 `0 ?. J# z: A5 e: ?& ?8 D ; open ‘cmd’ in the current directory
( O& {% R* n& x# X4 |# h" o ;7 M u% `0 q( ?- C& ^
#c::2 |( ~% r1 B. D' u. X+ K P, a0 w
OpenCmdInCurrent() Y7 b9 I$ I ~: ]* j+ l
return* P. U; t* a/ N7 w/ M
#IfWinActive; K5 D G+ z% D: S4 t2 b
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
2 M! S! @! A/ n ; Note: expecting to be run when the active window is Explorer.
% |' c8 F' E/ P- F( f! s ;
( B1 p N( ^% i1 \: _ OpenCmdInCurrent()
2 |0 ~8 x+ H4 g% E' y' W! h {
. w8 b' [1 d# Y8 _ A6 R$ E+ b ; This is required to get the full path of the file from the address bar! h1 h f5 | Q
WinGetText, full_path, A1 y$ v, P7 \/ s$ ~) l
; Split on newline (`n) I) M) f# L( b
StringSplit, word_array, full_path, `n
& l% e( D _& R# C, u) e+ R ; Take the first element from the array0 G( U; W1 N5 c5 v4 ^. L, x) k
full_path = %word_array1%- l, y; V( e2 }7 O7 w, \9 Z( s
; strip to bare address
7 | G2 v! S$ q5 j9 K- B1 K# k full_path := RegExReplace(full_path, “地址: “, “”)% x; [1 a' B; L6 {4 W! m" H$ x& l5 [
; Just in case – remove all carriage returns (`r)
s0 x1 l0 d/ k5 s& {& b1 u' e: v7 H! O StringReplace, full_path, full_path, `r, , all! U; r% ~% v9 x5 S0 R* f. p
IfInString full_path, \! `$ f& |5 l& g" t
{ W8 t" e: c2 i% g& [; A0 F5 O
Run, cmd /K cd /D “%full_path%”
' }& L' V9 y! _ }8 G: |9 J0 p/ i$ |6 f7 r
else
& M. w$ p8 u4 V B' } {5 l; l3 H( b$ @& F; G& B
Run, cmd /K cd /D “C:\ ”% h- q. M, D' n: T& s
}
9 G9 \, {. y& {8 W }
9 B+ `# s9 [0 p 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 h# u- t% X4 U2 y 这段小代码肯能有两个你需要修改的地方. P# m1 J, W# e& p# R2 [% w' A
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
7 s( D- t6 m1 w. q+ G# L% K 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; ]$ Q% e: Z3 j0 b) c7 p
|