此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。0 ` O7 G% `3 e& R* g/ M: Y
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 w- M ~/ b5 `1 J& x' F" x0 G 方式一:6 N. b9 J8 e$ O
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
5 D9 v; \0 J/ s( _( { 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
: F- A6 q! b0 l7 `$ q% N HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。5 w* b! l! Q% l7 h6 O9 ~7 b2 g3 B( x
方式二:/ r! ], @: Z) ~
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
8 S$ A0 b' E$ _- `. m SetTitleMatchMode RegEx
5 m2 F6 a3 q+ |4 K- ? return
7 U1 ]2 j* q4 v# i& O5 C/ Y6 H ; Stuff to do when Windows Explorer is open
# d* x0 Z* W4 n# ? E# S0 Y ;) Q) d( n8 n5 ?' l/ b# s* ]
#IfWinActive ahk_class ExploreWClass|CabinetWClass( N4 Z5 k* A6 q* J, A
; open ‘cmd’ in the current directory" ^0 ^) {% f- R/ Z
;5 J) ~+ d$ {6 T' b8 w* l0 j
#c::
& Q6 Q5 \/ M. k( D, e2 V& _0 f- a OpenCmdInCurrent()
4 j4 l: d; U: }. S2 R) O' r return
6 ]4 X. M8 ]% m4 [0 A. F& q #IfWinActive: c2 `; {: h' x p( [
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
) b$ f! _. w/ T6 N/ z ; Note: expecting to be run when the active window is Explorer.$ N/ R- W* ~7 C1 z; g
;) G4 P5 K2 s) H
OpenCmdInCurrent()
2 K0 O- `- B" V+ p- p& t- m' ] {
! ^0 c9 Y( ~, P" s/ r3 ?9 P+ n. N; t ; This is required to get the full path of the file from the address bar
; ^& K5 U* \- V* M l0 S WinGetText, full_path, A T( y" `& ~$ z+ X: N q1 P3 P( r
; Split on newline (`n)
4 G! |: m/ J2 ?) ] d* ^, Q. u StringSplit, word_array, full_path, `n2 O; a+ I0 y/ T
; Take the first element from the array
* H$ q9 ^9 c( }8 k full_path = %word_array1%
- F* c# u+ w, Y- B( S7 F ; strip to bare address
( T% N( t% E% H4 ]( R7 Q0 K- m full_path := RegExReplace(full_path, “地址: “, “”): G7 \/ [( F H" R( B% e6 [; D6 U
; Just in case – remove all carriage returns (`r), M, Q9 [' K& q
StringReplace, full_path, full_path, `r, , all
: M& p x/ b% v! U: U# e' l! r IfInString full_path, \$ b7 e5 ]" ]" d8 J2 u
{
6 k$ o- G: P, K, T( N6 D1 j Run, cmd /K cd /D “%full_path%”7 G1 d2 T: O* U% e- O W! r
}& N. R: J: C+ Z0 {, g
else, c1 K2 n: \! [8 l' V& I6 _
{- j6 Z. Z" V5 Y M) o# L
Run, cmd /K cd /D “C:\ ”
7 D* A4 X. S- c8 z2 K4 s } S& R/ F$ \/ a+ z/ X# }1 w
}
+ M2 }' J% c5 @* S$ l. { 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。, M( ?6 t* z$ {+ s/ e) t
这段小代码肯能有两个你需要修改的地方
+ |0 t2 N |% t% }' W 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键/ h: O3 c8 f9 a, \/ Z
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “) n$ l9 e! }# r& e. J1 y1 J {
|