此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 h( G6 j9 }1 C; X5 O3 e
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 v/ e- s% c$ U5 C, @1 E& c 方式一:
3 l z4 @7 \: s5 ^ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,. E8 S" W6 [# c# m
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和4 J4 _5 U9 }& G( u! k- F. W4 T" X
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。; \6 P& d) ^* X/ m. G5 X
方式二:
: [# u! D( ~3 H$ B& P' j. j/ U 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:. s/ N: i7 u8 @* r4 B: G! h( `
SetTitleMatchMode RegEx+ t8 n7 [ P# F* }
return
; C! V4 c1 q* P f2 Q4 e ; Stuff to do when Windows Explorer is open
# B6 _& `$ {' E. r: r ;( U6 k+ ~0 z3 e1 z
#IfWinActive ahk_class ExploreWClass|CabinetWClass; ?3 {' l; k9 s4 H1 W
; open ‘cmd’ in the current directory/ O! X3 t& y2 N# _
;( e7 s* Z! M) ?. q# [0 `9 ?
#c:: B& _* ^! L: X; S# y7 ?2 }
OpenCmdInCurrent()2 r9 P/ @2 f& ~ J7 B
return
) y) r1 E5 I- d; z #IfWinActive
3 L1 h% G# W: K ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
% c$ C$ Z! l \$ b ; Note: expecting to be run when the active window is Explorer.2 i. Y$ ]: a# o6 s% X8 ^" I
;
* E- y! ]3 O% a& X OpenCmdInCurrent()- d( S M# ?/ f* k. a1 k6 j8 Y
{
+ t5 S2 L6 H3 x: I ; This is required to get the full path of the file from the address bar: y$ [( m L2 N* O" R0 i$ I
WinGetText, full_path, A. u* T% b) L4 S' O* D
; Split on newline (`n)6 t$ I4 h2 W6 `! V# g l+ n
StringSplit, word_array, full_path, `n; m9 E& i6 _1 p$ I9 E" c& G
; Take the first element from the array" C" Q0 e+ f; O: W% l, H4 m& j
full_path = %word_array1%7 w. s: `" P5 B( F
; strip to bare address
4 t# @8 a5 k: B, t5 G full_path := RegExReplace(full_path, “地址: “, “”), R" m' o+ S- E/ @1 D
; Just in case – remove all carriage returns (`r)1 Y1 ^4 a* K l# r/ X
StringReplace, full_path, full_path, `r, , all
5 `, U: Q7 t0 B% U& f IfInString full_path, \, e# M; `: R, z. ~0 Z
{; R. L5 v, v- u. F. E3 b }# M
Run, cmd /K cd /D “%full_path%”, ^5 f4 t) _0 [; ` `! Z2 z
}/ u4 D3 L* e E+ w4 ^# G+ S
else: i l' ^# f; s! L7 F
{
/ f/ d9 D; P+ A* x. \- r& L5 g1 ` Run, cmd /K cd /D “C:\ ”
0 ^9 M6 W) T$ f h2 X t }1 U N! q' {1 ]
}
( N2 [$ q. p* P 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
( a( y+ v( I: T9 W9 m5 g6 j9 U 这段小代码肯能有两个你需要修改的地方0 y8 ~, W9 o B1 Y3 f# D
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
% P* E5 N8 F; [. }% P 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 z: `4 K' f0 T: B; ^) Y, q0 D& `2 f |