此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。. n) s( ~# M# B) |4 c. t( V
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
& { t5 |3 x, b 方式一:$ t) I9 f* z- I) K; r( P2 A- n: c8 [
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
" m) r3 R: @& m# g/ u7 q 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
" u! C0 [) Z0 ^+ c HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。$ H7 F7 z9 y6 \8 \
方式二:0 `& Q# p9 J8 g
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( z2 s5 l" F. B6 J SetTitleMatchMode RegEx. Y, p# T% ~* N4 }
return2 |. V9 N2 u" M% h) ~2 Z
; Stuff to do when Windows Explorer is open
" l$ ^: S8 z7 t8 u+ m* W) i ;- C% `9 d+ r+ _, [1 z
#IfWinActive ahk_class ExploreWClass|CabinetWClass( \% C: A: Y% \4 Z
; open ‘cmd’ in the current directory
' k. ?# O, H& ]0 {( g ;: q: l+ [: l5 \; t
#c::1 p: W% Y% j9 h+ J5 M2 L
OpenCmdInCurrent()
* ]- |8 P3 G: } ~- M return* n( s, F5 j' f: H
#IfWinActive" t- |: z' ^7 v/ q# C. ^1 Z6 `& F
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.6 h" D; G/ S9 e& X
; Note: expecting to be run when the active window is Explorer.
8 M8 u9 ?$ @/ c) {% z ;
5 p" e9 N8 g1 m0 c# Z OpenCmdInCurrent()) m0 D5 W) T) c9 T. |
{
4 B, b: q0 {, F+ Y, g3 j ; This is required to get the full path of the file from the address bar# a5 O1 p1 r# r- g
WinGetText, full_path, A/ @* I: g" `5 h" ]8 h0 v, e s
; Split on newline (`n)
( h& `( A+ ]2 z StringSplit, word_array, full_path, `n. B) H" T. h- T0 x
; Take the first element from the array
; i% T' m' b3 k1 S6 F full_path = %word_array1%/ T$ e, j8 h# e3 b' ^
; strip to bare address9 _+ h$ t3 S& h- X" a
full_path := RegExReplace(full_path, “地址: “, “”)# ]5 D+ y( ?( u# L/ V1 b! h
; Just in case – remove all carriage returns (`r) f9 \' n8 n3 ^* ?& I
StringReplace, full_path, full_path, `r, , all5 e( f# O2 X' W9 ~
IfInString full_path, \: x( o8 ?* ? }: Y) r
{
4 ~: y9 |* H- c Run, cmd /K cd /D “%full_path%”
9 N4 B1 n7 z5 R. U* e }
0 {/ U2 x; f; g2 x+ _4 L else
: i b* N8 Y" V b+ H {
( D6 N; _8 y* q/ v Run, cmd /K cd /D “C:\ ”" `9 c4 s0 [# x0 }' O
}7 ~' n% ^; V1 f( s3 B0 a3 n* Q
}; ^& k. _- E, ]" q& B& |2 i
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
8 { \5 F, M4 D 这段小代码肯能有两个你需要修改的地方 v3 v/ @3 B. A! x
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键, [! P2 T0 `* F( S
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 X6 F( \" ?% g
|