此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。+ A, f2 t* g& r; e4 r
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。, p) G/ g1 f9 g4 z+ m3 ^* f1 R
方式一:* ?* H) j4 e% Y# E; t; G
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,' }% r- C8 H0 d5 C5 ]! s2 a
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和6 a4 x: l4 i7 O9 G: m7 C& Z: }
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
7 s+ j* Q; u( w0 K 方式二:+ {3 [, c: W# Y+ |' k+ {
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:' Z" e- j1 |$ u1 n: C
SetTitleMatchMode RegEx
8 K% o+ k0 j3 s0 z return
7 R, O3 ?5 b! [0 D, |" q ; Stuff to do when Windows Explorer is open
$ R& F3 Y/ ?2 g- y, v ;
+ u* e/ r% Q+ a. {3 w0 U3 | #IfWinActive ahk_class ExploreWClass|CabinetWClass6 T3 `: k; ]# R8 H/ J
; open ‘cmd’ in the current directory8 Z' F) N a8 n- X% X( y# d
;
& T! ^4 I' P7 Y #c::
$ e6 z! f* ]% v8 r0 g$ ^, R OpenCmdInCurrent()2 d1 S* e! r; L4 t+ T
return
+ y0 M( `& [9 i c) P6 ] #IfWinActive
! {& S! i4 P/ o& J1 w1 i- V ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.- Y9 E6 Y3 s9 X6 A* B! s
; Note: expecting to be run when the active window is Explorer.# J) E0 [/ B6 L* l n
;9 h1 g' u1 Q3 w% I( n! \6 C# s( }
OpenCmdInCurrent()
" Y9 y/ f5 f& T g {
' l2 w# R, M- G' [* O ; This is required to get the full path of the file from the address bar# N' B3 R. G4 u$ s
WinGetText, full_path, A) W0 V) }. i5 i& \
; Split on newline (`n)
* r) Q8 E, ?9 t' z% T) c# Y StringSplit, word_array, full_path, `n9 V, O2 c) I* V/ U% q6 _
; Take the first element from the array& j/ u& `$ {+ K4 j2 z
full_path = %word_array1%/ u& v. X1 e% Z
; strip to bare address
' U9 p# i! C- [: P- W# J. X/ b( \4 x full_path := RegExReplace(full_path, “地址: “, “”)
: V/ P* J: N2 X- j5 F ; Just in case – remove all carriage returns (`r)( v& }8 x3 t# u
StringReplace, full_path, full_path, `r, , all
2 o: B0 ^: Y8 r( S a- h IfInString full_path, \
1 J! ]* X4 e) _9 G) |7 X) V {
9 t6 A) e$ l" g Run, cmd /K cd /D “%full_path%”; E3 `2 X# p ^4 _. F- m
}
+ Z$ Q* ?! z6 ~; y0 v& u else
" i# l' K3 t- F* b- M+ r6 [' }7 @ {
- z/ p3 d0 U2 F' c Run, cmd /K cd /D “C:\ ”5 _7 G/ l9 k) O8 n
}; f: k( ~ P% d$ Q+ }3 d
}$ C2 H! n6 W. u+ c
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
% n* h4 B) m4 B, a 这段小代码肯能有两个你需要修改的地方
6 \7 T3 T5 @. Y! i1 R _ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
6 i% j4 P }" i8 l( o E 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) V7 F+ a1 ?5 l3 _* {) d |