此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。9 }- P; o8 ~/ V+ D3 b9 R( K
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
r/ n( s! v5 Z1 B( @' T2 T3 v1 Z3 [ 方式一:
9 K. u) g' E" n5 q y) |2 g 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
: S- x, Z6 g4 e) F" d 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
) J7 K, _$ W& Q. B2 j HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
; a# R9 C6 w% D: O% l# w 方式二:, @( b6 l- }/ X( C6 V: O( _) h
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
% H; }1 j. H5 e5 j8 h6 ^ SetTitleMatchMode RegEx
2 s, g: _9 ]' v8 } return
/ Y' J) M. T% [6 b+ r5 s ; Stuff to do when Windows Explorer is open, n( K! D* ~: O
;+ s1 I& X& ^5 z7 p5 w
#IfWinActive ahk_class ExploreWClass|CabinetWClass
5 d4 p* V" F/ z! q9 H2 M ; open ‘cmd’ in the current directory
# G7 Z9 Q! L2 h- k/ ^) ~$ P ;
7 ^5 \7 ?; Q. y5 J/ X% i+ H #c::2 A/ j) I- `) A3 \
OpenCmdInCurrent()9 @/ U* ^, X, \/ O$ c# w" w
return! ~' Q7 ~0 L0 @+ e5 |4 M, S) p
#IfWinActive2 N/ t A2 A0 i" @* w
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.8 }3 b8 H- k) Q. O7 @- \* E: P
; Note: expecting to be run when the active window is Explorer.6 i+ l& @, A. n
;. C5 O# j' `$ R2 t1 g1 K& c
OpenCmdInCurrent()
' V3 z6 v6 \: I4 ^( x {
! b8 v8 U. {' D7 F ; This is required to get the full path of the file from the address bar
: s) w, }4 t' L. _7 p8 p: u) H WinGetText, full_path, A8 {1 V0 T/ v: R" p4 [
; Split on newline (`n)0 E b2 Z7 h6 ^! S" T7 Y+ V# _+ s
StringSplit, word_array, full_path, `n
1 B+ P. r) m- d5 r2 [& j2 A ; Take the first element from the array3 Q' g0 g1 e' d2 e. H! V, M- ?
full_path = %word_array1%
7 j6 W, B* Q* ?6 s' j+ }4 F8 n ; strip to bare address; j4 p' s& g4 |' [" B6 ]
full_path := RegExReplace(full_path, “地址: “, “”)4 d' Q: O) U" ~
; Just in case – remove all carriage returns (`r)2 [3 I" P6 n2 v3 @7 A
StringReplace, full_path, full_path, `r, , all
2 F; G- \, h Z3 o IfInString full_path, \
. U2 ]. x6 }% ?& I8 G {
. A% V0 f$ A h8 N5 d+ l4 M5 W! t Run, cmd /K cd /D “%full_path%”
# _. @2 L* e0 Z8 Z( P. R i }
* _# W( w( W) x% Q else
, _/ U# ]9 w C7 ~( ? {$ x. r8 {# _9 a* h* q* s
Run, cmd /K cd /D “C:\ ”
: D( h1 v+ h/ R. T }
( {4 m u1 ^; F+ ] }1 ^5 w8 X* m, `- U
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
( \- q) \! H6 d; G" u% ? 这段小代码肯能有两个你需要修改的地方
) [; X2 x' q+ _" {! ? 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键 @- q ]1 O* ?
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
+ w% Z; I! G* V) h& D& ~, u |