此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
" W- _9 v4 e9 Y' ~) _$ m7 f 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
5 l. M: n' `9 a/ N0 u5 B 方式一:0 Y, M3 I+ l. h
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
! W4 }* i! o- b$ H9 |; @" |2 M; _! E 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和4 {: o1 q/ ]3 b. z1 E! e
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 F% T7 T0 ~! s# t6 d! e% u+ D+ ] 方式二:* ?4 L' N5 j4 G
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 y7 K; o! e9 f2 l6 g0 I9 Y- |
SetTitleMatchMode RegEx. U% X% R2 ]" }7 Z1 ]5 B
return
: R) n# e0 m6 V7 C- u ; Stuff to do when Windows Explorer is open
" t- e( M! f, t. H# I: ^( r ;
+ e; q0 e& X. h; U5 ~5 W #IfWinActive ahk_class ExploreWClass|CabinetWClass
' G: H4 Y/ ?/ l ; open ‘cmd’ in the current directory; o8 E8 g" N8 W' n4 T" }( i
;; E& J6 l. H1 U! X$ c
#c::
4 v+ G' J( r' o+ w, v OpenCmdInCurrent()8 ^1 T+ T# Z, y1 @" m
return
1 B0 e8 b7 W! o) c4 Y# |$ h #IfWinActive/ u; L" F( F2 Z6 C; J9 X( ^( L @* C) z
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
& p% `) S) y) |6 k: |/ m ; Note: expecting to be run when the active window is Explorer.4 N& S* }# E8 {9 O
;) X( B' Q$ i& ^
OpenCmdInCurrent()& p; s& v9 \3 s8 I
{, R: Q5 f5 f+ ~& i: \/ D
; This is required to get the full path of the file from the address bar
0 j3 f, b, N" ?8 t1 ? WinGetText, full_path, A- Q1 v* N$ y5 F2 `
; Split on newline (`n)3 J% O0 P' `5 i" u. v3 L, x
StringSplit, word_array, full_path, `n
" O m0 U9 v* w) H$ ~7 K2 r& L ; Take the first element from the array, g. v4 |2 j( m1 x9 U
full_path = %word_array1%6 ~( A- b. Y8 z
; strip to bare address
, B" p6 n: n3 {* Q7 ? full_path := RegExReplace(full_path, “地址: “, “”)
+ O8 g. S. G: l7 i% F# M c1 ?: l( t ; Just in case – remove all carriage returns (`r)9 y' Y5 N1 w" N- P# N4 x9 |
StringReplace, full_path, full_path, `r, , all( E! n0 n9 V& e$ k, U
IfInString full_path, \
, Y" `$ u0 x3 q* g, }* `# v6 Q {
" f/ [ P" P. ^7 o( v( X Run, cmd /K cd /D “%full_path%”0 a) k0 r* G! K1 s' `/ w. c
}
9 V" a, z6 z4 S2 f# ^ else
0 P2 |4 I8 U' Y* b: M5 C" |& V {
# L E* B, ~. S8 w, m: g Run, cmd /K cd /D “C:\ ”) ~4 [# z5 L+ ~/ O
}; _0 d& I7 s" A% M
}' x$ P& b# f$ _* s2 H# J0 @
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。& P6 f0 F# f2 t
这段小代码肯能有两个你需要修改的地方' v* \! H7 ]- H8 E
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
8 P- ^ E1 w/ o+ ` 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “ `6 n& W1 ^4 s4 N
|