此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
0 l0 V) {. L( \+ J 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! A) S1 o- e6 Z5 R% W% O t
方式一:
( E u# e; C8 A) U/ b3 O. a# q 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ N) J# ?- R2 n/ ~+ l
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
- B3 g# @" J1 d2 p HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ _( e/ C! m5 Q" Z7 h f0 b- { 方式二:% W2 e Z3 O8 J; a
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
9 o& I5 c0 U* _& ` SetTitleMatchMode RegEx, n$ {/ B7 I+ O ?
return
) F1 }8 `% s A0 j, S; ^* z ; Stuff to do when Windows Explorer is open" b8 D- |! Q4 o; x+ V
;% F# H* g( n& L( r" N$ J' _
#IfWinActive ahk_class ExploreWClass|CabinetWClass
- c( G# M# r9 R( u7 x8 w ; open ‘cmd’ in the current directory
7 ?/ R( Z# p0 ~; Q9 m ;0 ~$ w7 D% o/ v6 `: F7 a' r6 Y
#c::9 L j* I5 ^/ \9 z" ^
OpenCmdInCurrent()# `+ T5 c2 ?5 l* r3 j- h6 l+ Y" P
return) u& `8 m7 b1 P' n) f$ \! I7 y
#IfWinActive! z5 j/ U# _6 M. K3 M/ c
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.8 N8 A5 u7 t6 h" X
; Note: expecting to be run when the active window is Explorer.
5 j* q! r" B- f& _ ;. g2 p) P* n8 Y4 b& ^1 I) o
OpenCmdInCurrent()' {/ }4 W3 C. N3 g5 [; f- f
{
1 u2 j6 V! t' Q- [* |; A9 \ ; This is required to get the full path of the file from the address bar1 I; q: ^$ `8 @* Z2 M4 p7 g
WinGetText, full_path, A x3 Y M4 }0 ?+ T w
; Split on newline (`n)' H* A, M& u( o F) j1 C# h) N
StringSplit, word_array, full_path, `n9 f5 A& }! H3 Z: N) A
; Take the first element from the array
2 \! t6 K# x, H8 b full_path = %word_array1%, U2 p( A; C% O' J6 s' T D
; strip to bare address
' f; C1 d: O# t# Y+ h, e/ U full_path := RegExReplace(full_path, “地址: “, “”)& }6 q5 r b3 n# x5 W" A
; Just in case – remove all carriage returns (`r)2 c9 h0 _- C. ]6 C8 V5 u( F7 [
StringReplace, full_path, full_path, `r, , all
+ j* g6 h4 _/ F' T4 j IfInString full_path, \
( l L' n! @. r, p {9 X) k1 v" r. y0 r- A
Run, cmd /K cd /D “%full_path%”8 ~! o( c8 C2 r* l
}; `- |8 w0 G( C0 A& s# E4 {
else
6 h6 X* j$ @5 S. ] {
+ e( {9 C# d" e [$ R7 c Run, cmd /K cd /D “C:\ ”
' Y% l" w! j& R$ x }
2 N# J3 l2 u4 q) D1 w+ l3 ?. Z$ i* q+ k }* |, x+ q0 r& e' B
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
6 x4 h; Y+ `. m& X* T# w G 这段小代码肯能有两个你需要修改的地方
( i/ ?6 X) f) q5 T+ j 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 q3 k( R- r; c4 P1 N 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
2 |" [3 o( o9 Q |