此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- r8 v' s( _8 _; p! S/ Q } 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 k0 H) i9 n( t4 A1 S! G
方式一:
+ r. V7 g) D) V9 j, @/ H; H 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
: z4 @5 o# h$ E 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
& @5 Y$ d+ {" _/ W& F HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。2 x3 r s; \5 f# o4 l! X2 J7 ~
方式二:! J3 D2 V! _. z7 u0 A/ u- ], c9 D/ R8 ]
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
" v H8 w$ ?5 { w, P# H5 d2 C SetTitleMatchMode RegEx
/ L3 S0 X6 y/ v* S return
2 k; X6 ` E' ~- Z6 k c: L ; Stuff to do when Windows Explorer is open- e6 k% I# F9 X0 d9 k k: r) i
;
& m- @$ l8 k. ]) F" E #IfWinActive ahk_class ExploreWClass|CabinetWClass
2 A2 J% |9 O7 N7 T7 @5 w ; open ‘cmd’ in the current directory
/ P4 r5 j) e- _! i! U ;
1 ]) A1 a! p* Z# B8 v% G) }$ P: ^# u$ e #c::
6 x( K* n' y' f% ?# P( m( z/ s; r OpenCmdInCurrent(); [' |1 y- D. H3 U, M, q9 @6 f
return
5 X$ @ f# H$ e Y. P5 w #IfWinActive, X7 I* }) O, w- p/ j0 b: Q
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.6 a' Y0 r% n0 a; U1 ?; d
; Note: expecting to be run when the active window is Explorer.
$ Y7 F) o5 u: y: p' y, H$ w* W3 d ;
1 \0 k3 Z1 ^$ X `. } s$ j OpenCmdInCurrent()7 E1 e E& k+ \: R. ~' a4 l5 A
{/ K# I4 V. G7 x! L( F6 l" k. {
; This is required to get the full path of the file from the address bar
: c$ T5 P& F: d- l2 F. P) z' w) s WinGetText, full_path, A
+ B" c' y0 G9 V7 e( J1 E ; Split on newline (`n) U/ _# s8 D/ _5 `0 j
StringSplit, word_array, full_path, `n
1 r! W4 n/ A( q+ {7 q& q ; Take the first element from the array
; K' D' D1 I2 T% p3 @ full_path = %word_array1%
! w- R9 D2 Z' C/ e( N; e ; strip to bare address
* D7 q$ i) ?( U7 m( w( b# M full_path := RegExReplace(full_path, “地址: “, “”)3 w( k- B9 E5 V0 X3 R
; Just in case – remove all carriage returns (`r)/ v g1 }) T( D$ e: \7 _( n% h
StringReplace, full_path, full_path, `r, , all
# m% K& j. J, l% Z7 _: f IfInString full_path, \
5 f5 Z" @+ O) y$ M4 ?* P3 Q {
F7 ]9 e/ m) E) Q Run, cmd /K cd /D “%full_path%”
* ~" I6 g1 r. [6 v }
- I u0 N. {6 l6 M else
5 @9 j% K) y- { {2 d. [* X! v5 ~6 I
Run, cmd /K cd /D “C:\ ”* k, a) I9 ~+ v
}, H# f' B% i3 }0 m* y5 h+ G
}$ I! j. ]" }( t: n$ Q+ @8 H
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- M) f* V# |. [9 U# f 这段小代码肯能有两个你需要修改的地方
1 n- F+ j5 }0 ]4 l: o) l 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键/ f* V- v$ Q1 ~
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “8 @4 t+ K9 ]- \( ~
|