此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ K! t* H V: S3 D( e- q+ d/ V 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
+ E0 m4 l% g- ]* j9 e: k 方式一:
8 O; b; O- T- T) _- ?3 g. j7 I 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,8 A; p8 f8 c1 s+ G2 R- V
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和& ]! q7 z$ K/ H- G$ F
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。2 j2 m C4 ~+ `4 }# w- D* M
方式二:$ F. m. }1 h3 y3 Q
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:, @; F; _$ [. I4 h4 [
SetTitleMatchMode RegEx
2 E0 w% g1 h/ z0 Q, R return* U. h8 Z9 e+ \9 k9 J3 q* ^0 d
; Stuff to do when Windows Explorer is open
! ] u. E2 B, R" E5 b( r6 Z( T ;
$ s, a1 W7 r; [3 _ #IfWinActive ahk_class ExploreWClass|CabinetWClass- ^* X- u) O- _2 G+ A2 h; q/ O
; open ‘cmd’ in the current directory1 Y5 c* M m0 q7 M
;
- ]$ w; i* U9 q8 @! {; J #c::
m9 t' l, e4 c% ^% G OpenCmdInCurrent()
6 J0 e( u3 E1 X4 s& E) |3 K' X return* f( {3 E: M- K
#IfWinActive4 X A( f" U. y
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
, X+ _! ~' L: a1 k x8 ]9 h" B" A c% L ; Note: expecting to be run when the active window is Explorer.$ f- {" Z) \7 @# D2 [& A7 b1 t9 F
;$ Q6 E0 h( f2 |' C# P" h
OpenCmdInCurrent()1 @8 d6 m& f% Q& Q. J
{: c3 ]1 A# j5 Z% Y1 x% i
; This is required to get the full path of the file from the address bar$ [! A. M+ q+ u1 d
WinGetText, full_path, A3 B. M! r" O, H
; Split on newline (`n), `) ~' Z/ p! }; ~8 H4 [, x% m
StringSplit, word_array, full_path, `n
) S: Y2 I7 E3 q# d9 r ; Take the first element from the array
/ L1 M F7 Z% I3 _ full_path = %word_array1%# }) h( N7 b/ c
; strip to bare address
# M; [! h" o3 d i3 E$ C full_path := RegExReplace(full_path, “地址: “, “”)
4 s# c. a7 {: P2 ` ; Just in case – remove all carriage returns (`r)$ u0 a/ F% D, N6 d' j
StringReplace, full_path, full_path, `r, , all' O8 K! c3 K6 U1 \
IfInString full_path, \% J- H( t" K; s! v3 j
{" C# o- a9 ?3 ?: Q, C V
Run, cmd /K cd /D “%full_path%”
7 Q4 N( \/ S! r* A6 z }4 V8 G9 s7 o- W) g% I. d" q& b
else
( v' w& T/ W- S. L8 z {, n" B m9 }2 l, F3 ~) d' v% [5 e
Run, cmd /K cd /D “C:\ ”
4 J4 M0 M& U- }9 G }
1 J, g, a/ r0 A! _/ U }3 ` E' I5 s: P$ z1 I2 `8 _& ~
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。8 R1 v3 q d. F1 ]8 s& q, t2 X- ^
这段小代码肯能有两个你需要修改的地方
) g9 g* c& m" v* O/ w 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键/ ]. m+ b* ~4 r- y5 Q! e: G" J; ~
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “# A z# `" T& w
|