此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。9 m! m& y5 x0 G B9 `0 E2 e
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: J, F2 f, [4 M
方式一: ]2 D. M$ r3 b- V; T2 q
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
/ z- }7 p0 ]- \1 S( w4 D% |& I 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和8 t& [# O! N6 ?- E
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- e# m5 R5 g1 r& o) m0 L# V
方式二:% U. u, ?) f/ t( Y
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: \% H7 M4 P) `
SetTitleMatchMode RegEx
1 P$ M! i3 a& ? return9 D/ U8 n6 Z1 F
; Stuff to do when Windows Explorer is open
! W7 l6 c: N& V; O ;
1 p0 i# A# o, L6 U #IfWinActive ahk_class ExploreWClass|CabinetWClass
6 n$ v' n& t8 P ` ; open ‘cmd’ in the current directory
& R+ P3 f1 }5 {. y ;
6 |% o z* O1 T* ^. O. [5 _2 V, f #c::8 X( J6 R. ?% r! `5 x L
OpenCmdInCurrent()
: w* o+ o2 _8 O' I- d2 J# R return
) Z P$ p& x4 V# z' N* U+ J9 t- Y; l #IfWinActive
0 [4 p* J; V5 X: [ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.( D- Q/ ]9 @' h' o$ {, B1 s! t. j# R5 n
; Note: expecting to be run when the active window is Explorer.
: G6 i. u* Z: J& l- a ;
8 L) B" |* ?( d! V% z' F OpenCmdInCurrent()
4 `% P- G: D4 M) Z3 D# W4 G% c {
3 }; S+ u& e5 w! [5 h! G0 [7 j. [6 b( F ; This is required to get the full path of the file from the address bar
! q) k5 Y2 M8 e0 \6 e WinGetText, full_path, A- d, S' V! [: Q% t, [2 a
; Split on newline (`n)
" M k5 }7 d$ t0 s' a, E StringSplit, word_array, full_path, `n& d2 ]* L9 a! j5 t$ L
; Take the first element from the array
3 V# f* e2 j3 L7 e) T9 X7 f$ L full_path = %word_array1%& ^; f5 h* X6 z* h2 J+ Q
; strip to bare address1 z( O/ ^/ K1 b0 o2 g8 |( J0 }
full_path := RegExReplace(full_path, “地址: “, “”)! C0 J4 J R5 _* K
; Just in case – remove all carriage returns (`r)
* H2 w i5 ]+ M8 z; m& P e StringReplace, full_path, full_path, `r, , all0 M2 c+ W, ]5 B3 n+ B" p3 l1 _% j: x
IfInString full_path, \
1 E, i4 R) z o" w {
) Y7 w9 C R0 x/ b0 r1 B# ~ Run, cmd /K cd /D “%full_path%”
$ o r- \& d8 M) g4 a7 t. B i4 q& ` }
# [" _; g2 \7 W1 F* L! c( k else; U# g: b0 ]& q; O9 d
{
6 ]7 x3 \- C7 S( e+ W Run, cmd /K cd /D “C:\ ”
& h, v/ x% p! \6 p, V) y }
: j) g( v' i8 N }4 F! t! D# Q0 Z/ n
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。1 \" Q% W5 M4 e; N. z
这段小代码肯能有两个你需要修改的地方7 G: D: ]* u( s" L' g
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ w) v0 w* `' N, d8 | 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ ^1 W2 e( O, M* X! Q |