此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。: L: P+ {( L+ Z( m) |
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% I1 i/ z1 [6 w
方式一:
2 Q& ]& g- m- g3 x+ q3 |2 f& f 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( J1 H' \: i; n8 f4 H; z
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和% n! ?8 r. R; R0 E {; W" }, A
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
9 h7 [0 D9 M/ D" [, _ ?% e) ] 方式二:& m' v/ K! k1 K2 A% n
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:# n9 A) `1 n# W" P+ J/ @: P" Z
SetTitleMatchMode RegEx
( R, L+ w9 q q return i" I. j* f8 }
; Stuff to do when Windows Explorer is open
& M7 x2 B$ T# K+ x7 c: C ;
+ l% p* M' v: r3 e #IfWinActive ahk_class ExploreWClass|CabinetWClass
7 v+ `$ D! A; w% n/ T% j$ `8 I8 g ; open ‘cmd’ in the current directory a% a6 K) x V; C$ n5 W
;7 ^. Z9 \! v, I* [
#c::
7 \6 P/ @5 {8 x# b! H" Q; a OpenCmdInCurrent(); g) [+ x( o. O
return
: j( @6 _9 l$ c* u% @0 ~" ^ #IfWinActive- a2 }( z5 `" q0 o2 x
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 r- b z2 y$ e {9 S C ; Note: expecting to be run when the active window is Explorer.
9 o4 X$ Q0 t7 B6 V; p ;
7 p5 t$ U0 z2 Z OpenCmdInCurrent()
$ G/ z) e2 z- R5 B6 f$ p {
) v1 t& z1 H* R& j# C ; This is required to get the full path of the file from the address bar
, B! h& L0 {8 W9 U) u0 h WinGetText, full_path, A2 h" m) Q; g! s' y
; Split on newline (`n)
4 [& }9 y+ P6 G! Y8 k) g StringSplit, word_array, full_path, `n5 n: u' `) a4 |) \% z) d
; Take the first element from the array
( }! R% }' J$ h5 v+ ~ full_path = %word_array1%8 ]! @8 j' O+ ~8 C& \1 Q+ M
; strip to bare address% |( u+ E$ x9 g3 x
full_path := RegExReplace(full_path, “地址: “, “”): k, N% [) m' {
; Just in case – remove all carriage returns (`r)
2 t6 d; W- `; {3 i! _ StringReplace, full_path, full_path, `r, , all
4 X) [! D- X& \1 N" n IfInString full_path, \4 }, C, m2 W. w; C' ~9 m1 E+ V ?# @& Y
{; M! l3 B% C& m
Run, cmd /K cd /D “%full_path%”
y( m, h5 D/ ^: S2 |& T' z }
, _) D4 {7 x5 r% ^. o! i else
5 ^7 s: d* m( \3 l/ T x {/ M3 K7 I* p$ x" S$ W% w& d
Run, cmd /K cd /D “C:\ ”+ E- }. v4 p* u% l
}
( U" e4 J- D* }6 l' \, g3 W. Z9 U/ B }
) i3 e5 z- o. M i 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
. X; ^- _* \% \1 ~% B 这段小代码肯能有两个你需要修改的地方
6 _$ ]+ W; p- v U 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) P9 |9 w- M& @# z( g 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “0 F* L; \' P) d |
|