此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。1 @# a5 G2 C5 g7 p2 _5 E- P, ?
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
- ~- a" y! V" y9 F% T- p 方式一:4 w5 p& U% P" v$ h( F
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
1 G2 z- q' d$ C3 A# L: h5 r 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
! W9 b) l2 Z B HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。# x) E) p9 L; } R/ B3 D% C( I0 q
方式二:
7 u u6 t. J& d3 V) o3 X# f 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
0 y! @- f/ t# `7 t6 ^ SetTitleMatchMode RegEx7 s" Z/ W" ^' o2 u H* `& ?
return
1 v7 a# q8 b; T4 \: ] ; Stuff to do when Windows Explorer is open
+ J" _2 P: o" T _/ m& z5 V ;
4 A0 \) W6 D6 D& n1 j #IfWinActive ahk_class ExploreWClass|CabinetWClass8 s$ q/ T9 u/ C5 c' S
; open ‘cmd’ in the current directory
9 L* d7 k; Q* D ;9 C6 N2 m- @ d9 h3 M& j
#c::
. }' _3 T- K h5 L% w4 ^ OpenCmdInCurrent()
+ ^% {% ^' e5 S) e4 K c" Z1 d return
5 F8 h0 X o! o; F; `. O9 A. n2 y #IfWinActive( a# `1 L' G5 e6 V9 x( n. N* k U
; Opens the command shell ‘cmd’ in the directory browsed in Explorer." P6 Q1 j! Y/ V. F
; Note: expecting to be run when the active window is Explorer.1 G' R' X$ E6 Q0 G) E8 t
;6 }1 Q1 M* O3 c
OpenCmdInCurrent()
& s5 c% q# F" p: L {
+ P3 w7 L8 l, z% Y2 D ; This is required to get the full path of the file from the address bar+ i4 N1 U* v$ O
WinGetText, full_path, A
) p$ A# D& h% A ; Split on newline (`n)! K) ]; H7 B7 V* v3 [9 c
StringSplit, word_array, full_path, `n
- F b2 A% z: f* d* [ ; Take the first element from the array
* W* u% d Y9 X h0 V full_path = %word_array1% h! T, \5 \% E7 l5 F# T; P
; strip to bare address
( ^6 O* u/ X& o' ~) k% A4 M+ d full_path := RegExReplace(full_path, “地址: “, “”)
! d" o K) U% f) T- }+ B ; Just in case – remove all carriage returns (`r)
1 f5 Y6 _ S3 `7 e" i+ N b- j& I. P- D StringReplace, full_path, full_path, `r, , all
0 x) Y @% N/ U( F! [. Z, T! F/ L IfInString full_path, \
. G3 J0 d# J+ [ {
/ b, r/ \$ Y( K* M6 ^ H Run, cmd /K cd /D “%full_path%”! @' Y9 s' Y# i) y/ X3 w) Q7 x
}
1 w! `2 D7 C: u1 F" E; r else
+ ^/ E& C6 z5 } K6 S- j {
' b# L- c+ E& @. \ Run, cmd /K cd /D “C:\ ”
) Q/ _: B* [' m }
: ^8 ]! ?: ?/ O$ ^' @ }
4 ~+ _2 n& H( X$ O) X- [ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! c5 Q3 G: X- G' b; w* T, P4 }. |
这段小代码肯能有两个你需要修改的地方
* F; f( x) I$ w. ?$ p" N 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
% H" I8 C% b: ` v& P4 W6 ^5 g; Y 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “# A; Z) o$ m1 D {0 k7 J) B
|