此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
$ x5 K p: _1 A6 E4 ^ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
2 Z @$ q: c2 f6 E 方式一:
# w* v) u( v# w0 a; _' _ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,6 _( n' y3 @6 c) Z
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
( o; T5 L; q' p5 u HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
+ B) W! r1 B8 s 方式二:
7 m0 _) f: l6 X$ `- R* d- A 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:# ^& q) @9 ]( a$ o" `# @: i
SetTitleMatchMode RegEx
9 `" S) V5 k$ e9 U9 s' s" v return5 K" C, N& _/ z! H4 j! J9 [
; Stuff to do when Windows Explorer is open
% U8 n" V1 R# ~1 s8 ^ [ ;9 d( d1 w6 s# X# v0 P
#IfWinActive ahk_class ExploreWClass|CabinetWClass
' W5 @1 i& F, A- M9 T' S ; open ‘cmd’ in the current directory
" Q$ A! D3 h) `: c ;
. d4 ^9 v4 I/ d& i D0 y #c::* ?, Z* H0 F W4 I- F' `
OpenCmdInCurrent()
Y3 i0 k5 l9 L- G, U( b9 Y' a return7 B) v, {4 \$ v8 C, S& Q2 N
#IfWinActive/ N4 [9 }+ x2 B) V
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' D2 |( u, F. m1 Q' f# A& H ; Note: expecting to be run when the active window is Explorer., `: `$ p; u- q7 h+ A
;. ]# f. T( f* k
OpenCmdInCurrent()
( T! i/ A9 W( I8 `! ?; Y {: n3 c' ?( `$ `, D1 x. G' L! [* Z
; This is required to get the full path of the file from the address bar
4 V8 }7 C9 K/ x- o' { WinGetText, full_path, A
" m8 C, b9 Z4 K( {# m% u ; Split on newline (`n)8 v& ^3 q9 L d- E' |
StringSplit, word_array, full_path, `n! O# j, j1 \1 c, K- u' T
; Take the first element from the array
9 r& z+ u: g7 r+ P1 q) R+ p full_path = %word_array1%& T6 P; d- D7 w' a
; strip to bare address
, Z6 A8 A, z$ c1 z full_path := RegExReplace(full_path, “地址: “, “”)* `+ S6 S$ R4 n( o7 Z! |* Y$ \
; Just in case – remove all carriage returns (`r)9 o! z7 U; p G: _# w
StringReplace, full_path, full_path, `r, , all
0 O/ n O+ W" }+ N2 b! l IfInString full_path, \
1 K; C4 G5 p' f( O {) A( j% M) ^5 N7 n7 _8 z F) h
Run, cmd /K cd /D “%full_path%”& G: I) G" {9 h! w: {0 n
}
e" Z2 W$ g7 s2 J: E4 @ else! i" `/ G3 b# f# f2 k: J& Q
{1 t% G2 Y% u1 z: ?' @! y6 o
Run, cmd /K cd /D “C:\ ”" }* f+ V M3 \# B. G5 {3 O6 b' w& L/ P/ n
}
& C" I" k6 g) b# {) z6 q' I }
8 z7 R- t+ `2 ]: \' D% l5 p 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。' C" M& M; `, r) {6 M- c8 C
这段小代码肯能有两个你需要修改的地方
& l* O5 t9 w* w& ?: a% z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) o% k& K Q# q9 Q0 ~, @: F 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) D8 w! w; N3 ]( D: E* Y |