此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。9 U! O8 |! a' J4 S5 t. _
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
$ k S" Y4 i2 s0 ]4 B 方式一:9 r* g& j3 d5 |
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
. Z3 T( p* p- n 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
& e7 b# K- q: k: _) _+ P+ P HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
. H" q! U$ l- R" Y+ g; j# K& W 方式二:
& ]1 H7 L- H' _8 G3 m 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:' X Z; u% n1 J* l) n
SetTitleMatchMode RegEx
" m* @* z+ {8 W& O% j' l return7 L/ y- k, \! e7 } n
; Stuff to do when Windows Explorer is open
' v' M. o& U; G% O( @ ;- ^8 t& A) z9 K4 }
#IfWinActive ahk_class ExploreWClass|CabinetWClass! J5 }" H6 f5 v1 O2 s" y, `& w
; open ‘cmd’ in the current directory
" k, l J' \7 J o ;4 O/ l! t, j0 K- O) o0 z7 [
#c::, ^. w# x. f0 \
OpenCmdInCurrent()7 M8 o: {3 p: P( S
return$ l. @+ Q( W. Q: H) M. j4 l ]
#IfWinActive
5 f! }( b% L. ]7 a! n0 F2 d1 t ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
: K- @# L* v, ]5 v5 k ^$ _ ; Note: expecting to be run when the active window is Explorer.2 Z5 c/ } c7 }; y+ ^$ v! U9 A0 h; c
;$ y+ T( S$ [- i' y& f. Q" R
OpenCmdInCurrent()4 B9 m d* ~: s4 m7 l! ]3 x
{
/ Z& P7 L1 q* p& t1 o5 _1 I9 N4 D ; This is required to get the full path of the file from the address bar6 P9 Y7 m0 L4 z- S
WinGetText, full_path, A
2 t: H" e( l& C q* d! K ; Split on newline (`n)3 @$ A3 M* N1 [& j/ v. z
StringSplit, word_array, full_path, `n0 N- `" F, z) L6 ~: k
; Take the first element from the array
B9 h; \+ C+ V" a3 \3 \ full_path = %word_array1%
$ G' A' {; ~+ y* d. o, P$ a0 `3 k: Z ; strip to bare address
& G* y; i, B" k2 q& I# S9 u full_path := RegExReplace(full_path, “地址: “, “”)5 Z t6 @. Y( b) q& e# F/ n2 D7 l
; Just in case – remove all carriage returns (`r)8 b6 a! v- A: k, i! s
StringReplace, full_path, full_path, `r, , all
5 i. n8 u8 r7 m IfInString full_path, \
( M. a% O: p- u8 F. X# s {
* l, D* v$ ^7 g. X/ [4 c Run, cmd /K cd /D “%full_path%”
1 l. ], K/ w7 @7 F, b' R! ~% T }9 W. G0 p& `" J, G4 T, {
else2 w: a9 L, b9 \2 x
{
' R. ~1 ]! p' i- x X Run, cmd /K cd /D “C:\ ”& Z; a) S. P0 f
}7 K* l! |% T3 @0 p; R+ q" c/ k
}
3 F- @+ Y# y9 ^9 _ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。. q9 [: X; A g( J
这段小代码肯能有两个你需要修改的地方; |5 n( r4 b6 T& b# z7 |- X
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
; d1 U9 H. i; g; t5 E' \7 H 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “8 E4 H& ^7 H) i) I8 }+ U
|