此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
0 E' P! `9 H. G& D( K; K 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。) e' W- D$ P0 s- u0 | a
方式一:; j0 g* {+ i" e. q: L0 i
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
7 z+ [0 s3 Z. A 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
# K6 w0 y0 J" G. c3 B2 P \ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" W) h! ?% z0 t3 z: B* g
方式二:
+ \' d" O5 Q6 Z0 o 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
9 l8 q1 D$ @# g4 x, a# V SetTitleMatchMode RegEx+ {6 y) j6 Z) K; C
return
4 e. m2 ?) b; _ ; Stuff to do when Windows Explorer is open& L. L% R4 I1 f$ y. U. Y! c3 \! {
;
L7 {' C) ^6 ~7 s; G' p# E5 s #IfWinActive ahk_class ExploreWClass|CabinetWClass1 ]# g0 ~" L7 s9 W# N" j; E
; open ‘cmd’ in the current directory
0 s0 F9 b0 P) I7 @, V ;. p/ C8 U( g* g- p. n1 \4 v* U* L
#c::
! N; J- U/ K, H* c OpenCmdInCurrent()
! v, G4 `4 M+ L return
9 a' }& \! W: @( d% M #IfWinActive8 Q) d# I! x2 v6 y# f1 y; g
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
2 s' [; e3 ], L( V4 S2 o3 b ; Note: expecting to be run when the active window is Explorer.% u0 I2 v$ P( X" E, \
;
4 {4 s: w j" Q" a OpenCmdInCurrent()
. [$ H- }! Z" H- R) A0 t6 d @ {: P# Q0 q0 L: r& X& {) |
; This is required to get the full path of the file from the address bar( v. I3 r B$ ]2 p: M. Y7 f9 H
WinGetText, full_path, A
4 O# N( \- R) f6 V+ \" y' E1 E% f9 j ; Split on newline (`n)8 R: a! `, i, s" {% i& \
StringSplit, word_array, full_path, `n
! @: f2 D0 H6 a O' p ; Take the first element from the array
1 Y% E5 b* o# G1 G full_path = %word_array1%. u4 }/ h6 U3 y, j7 ~2 N
; strip to bare address
6 }6 J. j' m: Q full_path := RegExReplace(full_path, “地址: “, “”)
- e% d, t, l U q n* q ; Just in case – remove all carriage returns (`r)
L' q- [( O. E2 X q( X StringReplace, full_path, full_path, `r, , all
# s8 I6 I1 _, ~ IfInString full_path, \
3 [6 Q' D8 K" R# ~$ x9 |' R. n/ Q+ x {
# K7 z, W' H6 \0 }6 R$ R1 ~8 e4 s Run, cmd /K cd /D “%full_path%”
# ]+ f& V6 R% `& |! B0 K0 i7 L5 g }
+ e% c6 n: e/ g- X else
' f& X' q/ \# Y; u2 e {
& G8 N3 f7 T3 O% } Run, cmd /K cd /D “C:\ ”
- @" _1 x' A, u& _7 {8 d v1 \: `0 w) c% ` }" X1 j" o" B; Y' z
}+ N+ M) b+ X9 I
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! c. H5 H D1 F
这段小代码肯能有两个你需要修改的地方3 f1 B' }1 E) O% X; O/ e
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
9 h, D: i" }* r* G3 e8 J 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “0 |, K) u' r ~9 {
|