此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' ] k" K1 C+ m* B9 s: S$ }
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 u& @- v/ ]" q( M( f5 B 方式一:
' A. l1 |! }, W g. L7 V1 r 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
. z% u7 p! ^! g: ], W8 G: L7 j/ q, P5 D 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: g' {3 e5 T) C$ B0 _5 _
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。. {' c l$ [; W8 l, h
方式二:" R- B( d% Q' u8 {
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: A+ d- v" x7 C% i8 \( K) n
SetTitleMatchMode RegEx5 g2 k8 o6 _9 N" W
return+ j8 [3 w/ X# Y, o. r! P" B
; Stuff to do when Windows Explorer is open
8 [* s. m1 [- U: I' _ ;
! i% f$ T# T8 Q# `3 e #IfWinActive ahk_class ExploreWClass|CabinetWClass# D( D- ^" S* N* p }. [
; open ‘cmd’ in the current directory2 G7 {' ^5 B0 ^# e/ |1 f1 F( C
;# j, g; D, `' K e' O! _* Y5 D [. j4 Q
#c::
4 G! x! C1 |" E4 H1 N OpenCmdInCurrent()5 n' v! Y6 z- @4 p" g* H
return
9 d/ ]: h, n: `& ~ #IfWinActive3 J, I1 L8 U0 q3 }4 m2 X& D
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 `; E9 D+ a5 W7 k4 K$ x
; Note: expecting to be run when the active window is Explorer.
6 o0 L. q( J1 L. u3 N( Z1 A/ G1 s0 b ;& Y( i% i' w6 K, P
OpenCmdInCurrent()
, \7 `; F! Q2 p d {1 M2 D* P6 x9 t0 m6 c: A
; This is required to get the full path of the file from the address bar( K# {, T+ L8 y0 k- C/ O% E" Y
WinGetText, full_path, A
" M) c6 I$ ?$ ? ; Split on newline (`n)
, E/ ]' Z( L8 C" w% y% c3 t StringSplit, word_array, full_path, `n3 R/ b4 F+ F( i. k% G
; Take the first element from the array
( s; H; y- R1 S4 W: i6 w+ f' o5 v' O full_path = %word_array1%0 B k3 N! A7 H7 C
; strip to bare address5 `) b5 {: k4 f/ f; {
full_path := RegExReplace(full_path, “地址: “, “”)
+ J1 Y; |1 U. L) R5 O ; Just in case – remove all carriage returns (`r)
6 X9 V8 v, u- R StringReplace, full_path, full_path, `r, , all% K9 S6 m. {$ @* @+ F: c0 x
IfInString full_path, \
/ {% e8 i! D( K! ^8 G& o {
& |- K) e( v- R Run, cmd /K cd /D “%full_path%”
% ^2 ^* Q2 [: e# u" d' v! e- j/ S# K }
+ Y0 G, M1 Q7 Q& g" `5 H else
: n- e2 i8 C3 c4 ` {" D# r/ G- S: z
Run, cmd /K cd /D “C:\ ”
, M4 f' e. W- L2 o D h }
3 F! H9 O d9 E& l) J }0 B$ a4 @: i- b# l
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。1 Q9 i3 h7 W0 G; F3 Q
这段小代码肯能有两个你需要修改的地方
7 B/ g5 ~- @; ^ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键# m/ e& r, L/ N" s( b. j# m3 H
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; d& o5 a/ a) [1 {
|