此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 b; b6 ^" S4 q6 X9 ^ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
/ j, d& k D3 g: _4 O. B 方式一:
/ s/ g% u5 `$ M4 ?" | 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,. C; G) ~9 G$ h* U0 O
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 W. `* ~ e7 ?1 a. u
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
% a: \5 a- R) B3 D* k) }# l 方式二:
& K9 R5 Q9 I/ R1 t. E0 |6 j 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:5 u2 E. D& o2 I2 n/ B9 M) Q: q
SetTitleMatchMode RegEx# V1 q% Q5 n0 q( B: }% i( O6 b
return- c5 K/ V# u" G7 X0 O
; Stuff to do when Windows Explorer is open
6 Z# R3 d2 s' j) O$ x+ G ;
; v! ~( z% W+ z2 S) L* k6 R4 k0 r" L #IfWinActive ahk_class ExploreWClass|CabinetWClass
; ]8 x: R5 k. P( s8 N3 e ; open ‘cmd’ in the current directory
6 b6 }6 `1 J7 o/ i/ c ;4 d& D' q$ Y" R* k9 Z
#c::
/ o# i" e+ a' f OpenCmdInCurrent()
1 x7 ?6 `7 h) T+ G$ Y return1 C4 f \4 X! d8 }' L
#IfWinActive
" L1 ?2 y1 D$ G- ` ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.. @' ^0 T# ~8 j7 _
; Note: expecting to be run when the active window is Explorer.) ]0 ~$ s+ j# o
;4 {; R6 C# }' `! Y! Q1 W' m" I
OpenCmdInCurrent()! u8 Z2 x. u2 F- T6 N8 w
{4 r; W6 M( D1 x6 I/ @
; This is required to get the full path of the file from the address bar
& H5 b, l. H& t0 E WinGetText, full_path, A0 w0 B/ T, b# ^9 p$ P L+ [
; Split on newline (`n)
# U& N; t8 n0 ?8 V* U0 Z* \: q StringSplit, word_array, full_path, `n' S* f. K: s2 V1 |
; Take the first element from the array
- W v/ y* A) A6 P5 x* e full_path = %word_array1%
5 a, o2 |5 v5 p. D& ? ; strip to bare address D! e6 b x0 v; E" n
full_path := RegExReplace(full_path, “地址: “, “”)+ K, H0 j5 |; u2 B: e( q0 Y
; Just in case – remove all carriage returns (`r)0 p( p* y6 ?' D7 k* U+ u8 g9 p
StringReplace, full_path, full_path, `r, , all4 U. L6 J9 }: K S. y
IfInString full_path, \. q A* p+ ~1 O9 }! X o* N3 j0 Z
{3 X2 q7 L+ }' e0 V3 c( K
Run, cmd /K cd /D “%full_path%”
# n% M6 d A- x4 w }8 |0 N" S. L; K% `
else
1 B' X& A J# B# b% F. Q# g {
: T$ e, |/ m2 Q/ L. b8 ]1 h& T+ k8 R Run, cmd /K cd /D “C:\ ”/ g. V0 r" o) D) g, N* `! T
}
3 R! S& u3 ]( l0 N% A( j W }
; H1 C1 P- Q) ^! I1 ~ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。4 S7 h9 p5 j6 n
这段小代码肯能有两个你需要修改的地方
8 R8 L9 y6 H( H$ @( M M- b$ d' T+ @ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键% w3 ~+ {& E' U- b1 j$ T. P' U S0 v6 s
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “/ ~" G4 H, M' q/ V( v- y x
|