此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。- e# ^8 _) ^' M8 K* G
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。4 j" G$ f# A: }
方式一:& S$ p& u% d& U3 E5 g
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 d5 a, i/ y! J8 Z- B, q2 Z
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和* A( w9 v8 ?8 [5 s6 T
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
d/ E1 r; G W/ g! C5 e# o& U 方式二:
- E' `* w. J5 E3 c" U 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:) O$ @/ W/ w) x" j! O+ ^+ Y
SetTitleMatchMode RegEx9 t" W0 Q, H; j- Z) |% I, q
return4 q( |; y) W. Q; |; J
; Stuff to do when Windows Explorer is open
; s7 ^8 S$ K Y1 { ;2 T0 i' a* a& k/ ^4 v1 g* V
#IfWinActive ahk_class ExploreWClass|CabinetWClass
w3 L( h O/ ]. u ; open ‘cmd’ in the current directory
- y/ t& t0 y" ^8 V6 E, b ;
/ x8 h, d0 E9 | G1 e0 s3 r' h3 G* A2 L #c::
$ C: p: X0 G B- ^1 o. k OpenCmdInCurrent()
* K, M1 G- w/ g3 y- | return
9 P+ B8 J& Q* ~6 s6 t7 C #IfWinActive! m& Z* {# f0 O/ Y
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
- K+ C" V" r7 k' N$ _/ W ; Note: expecting to be run when the active window is Explorer.# X3 n9 {8 Y/ \
;
" Q9 @% s H w" i% M% E# t OpenCmdInCurrent()
/ H9 M" _; H E" F2 v3 y {
- z; o# ~ k9 d3 S( D ; This is required to get the full path of the file from the address bar2 d, p3 K, p( y' h
WinGetText, full_path, A
; L$ @, q- k) _% @. Q ; Split on newline (`n)
' b+ m9 j2 ~/ L$ E StringSplit, word_array, full_path, `n
; S) D8 ?% i0 H( O9 }0 s9 Q ; Take the first element from the array* K) Y! u1 y) z, l
full_path = %word_array1%/ ]: [: D: q* R' H
; strip to bare address
6 S/ O8 D# w/ R+ P& s$ v full_path := RegExReplace(full_path, “地址: “, “”)
/ g) Y/ c+ S! a2 S* h+ Z ; Just in case – remove all carriage returns (`r)+ ^& e# z: U+ n( d
StringReplace, full_path, full_path, `r, , all
$ w8 F8 g# G3 z4 I' } IfInString full_path, \- J/ r3 ]; I) _) d
{3 x' ?, }! B: p$ k$ P- @* U5 I7 r& O
Run, cmd /K cd /D “%full_path%”
6 M0 Z3 T* S6 B9 c% p- x$ K }
6 J/ E3 [7 h, @1 x* A+ L else; e% O' N4 W1 w2 p/ `6 z9 B
{# ^- Z8 U- A8 `; [, L
Run, cmd /K cd /D “C:\ ”2 _% m7 `1 N4 r
}. o m) \, P- ], W/ ^
}
+ t5 X) [+ ]$ n; Y$ m& M 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。, e4 s6 ?- g6 B( k3 G
这段小代码肯能有两个你需要修改的地方7 w: R# ~7 v8 N( X
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键1 N8 L; H% p e+ ^1 S! U
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 s) g: J$ e5 q; g, G' E |