此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
8 y* R5 ], Y( y/ t0 A$ k0 p 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
* f g$ K+ H# b( o+ }8 ~ 方式一:
& @' T% n; c* S/ S, w 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
4 d* D7 D, }" E5 H+ D 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! O& S$ W5 s5 d" z2 D* ~
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ D2 G1 F! d0 i, B/ S$ \
方式二:% w0 D6 m$ @: a
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:* o$ r: Z! t0 D9 O5 S/ ?, X4 m
SetTitleMatchMode RegEx
' Q7 ^+ S- S( q$ ~9 {7 O return
( C6 z1 J* T7 p9 W3 N* _ ; Stuff to do when Windows Explorer is open
: H# _0 I$ x& M$ m1 ` ^ ;, \& f. c( X/ ~+ G& m
#IfWinActive ahk_class ExploreWClass|CabinetWClass
3 j3 n9 c2 p2 X+ e ; open ‘cmd’ in the current directory
: \- X! E( P2 ^5 n+ O ;
1 t: M6 K. j5 h! i$ k: b+ L #c::
3 v: k( i. L* r: X OpenCmdInCurrent()
4 {3 n6 C! r0 M; w return* _8 D* C; R9 x1 J6 U4 d5 M
#IfWinActive' I# J. t. L3 w9 k
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
- u2 F( H" D) h# r, p1 l o. o$ m; s ; Note: expecting to be run when the active window is Explorer.8 A2 b# \ A( s# y9 x
;
/ `+ I, y; L8 g OpenCmdInCurrent(): b1 a. U! X9 K) V$ Z+ r# t; o5 A" \3 D
{
9 w6 t# Q$ @& H2 `/ J' \ ; This is required to get the full path of the file from the address bar
! g. M8 _/ _% t/ `! G: U WinGetText, full_path, A
9 R1 _* R8 k% [$ ~/ L ; Split on newline (`n), a' \; D6 }9 M, _. l. w
StringSplit, word_array, full_path, `n o J2 p$ K. v7 k0 A. X6 r* f
; Take the first element from the array5 }9 z! C' B2 F3 ^$ }( |" B* E
full_path = %word_array1%
9 R' F5 O4 M$ S0 h ; strip to bare address
) L+ \% ]2 a/ Y; q% L1 Z" j9 v" U full_path := RegExReplace(full_path, “地址: “, “”)
1 g& e! D# m# Y. d$ E ; Just in case – remove all carriage returns (`r)
g* j' p3 F' y( f ~: p StringReplace, full_path, full_path, `r, , all
0 c) c* Q* ^& y; A' U4 b IfInString full_path, \. s7 t5 p* o K" O
{
: a. M. v% D1 G( P& S/ { Run, cmd /K cd /D “%full_path%”$ m- T0 O* H0 \$ V5 q
}8 e2 o: o' n: \
else
: A Z# g1 B+ |) h) t {
% @/ i- g) p6 F Run, cmd /K cd /D “C:\ ”
3 e3 v+ Z4 p& c- z M5 Q7 M4 [ }
7 L4 Q5 _$ i1 e3 L/ i7 P }
1 R E" \; ]( h 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
+ B9 G# x3 f- X- m 这段小代码肯能有两个你需要修改的地方
; }5 Y5 d" U0 ~2 [+ j 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键* X% O, d0 G+ H4 r
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
$ O. n0 d8 x* e0 a# H' S |