此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
7 e. L- H' T6 f( I 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
' L: i: I; ^1 p0 \( W9 V* z5 U( J 方式一:( T" Q* u) d) S
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表, t9 N4 d Q7 Q9 W' g- o7 a; }
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 x' r1 ~: V( r3 ^: F) P- ~ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
( Z3 e! f |6 Z9 q 方式二:
1 X0 L7 W6 R% t; N& `4 D0 p9 F8 I 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:6 J% y( ]* G2 F& r/ X2 W
SetTitleMatchMode RegEx- t4 e, l2 k' P+ _5 v
return b/ E3 m4 V) A7 c
; Stuff to do when Windows Explorer is open
7 {/ G }# K, [* a: p ;
/ P3 x9 N4 |* Z& A' l #IfWinActive ahk_class ExploreWClass|CabinetWClass
U! {7 x7 ?5 B3 p9 V ; open ‘cmd’ in the current directory# r' k( ] E) {- f. F
;* v& ]& b# C5 h" y5 E% l5 L$ m$ K
#c::3 c7 L5 D0 c$ H2 ~0 o. Z
OpenCmdInCurrent()
/ ?7 E. [# ?) d' g7 h return, C0 @, {: b% T, G+ ^0 v
#IfWinActive" ]/ e! s8 l& \) I7 q
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
3 H. H( k9 f5 |1 f+ z7 H. {( U; z ; Note: expecting to be run when the active window is Explorer.
# \( `# t! A: N* b4 @8 i ;
9 L& x* Y: g: N. B OpenCmdInCurrent()' y" ?0 z1 o' s) U' |
{
" w! L; B0 C K; N5 }. a ; This is required to get the full path of the file from the address bar
( I2 e6 N# _+ ?2 l5 m @1 p4 f WinGetText, full_path, A
2 \2 ^3 |: g; u* V ? ; Split on newline (`n)- L2 c3 \8 U8 ?0 b+ |$ n. d
StringSplit, word_array, full_path, `n
, n% A* }" d2 y) o8 S# m ; Take the first element from the array
& l6 i9 ]6 u; u full_path = %word_array1%. Z" l3 G0 r2 {6 y6 h1 x( R9 S
; strip to bare address0 q a( j, R. `) u
full_path := RegExReplace(full_path, “地址: “, “”)" b; D. C& I% _& s# V( Q
; Just in case – remove all carriage returns (`r)6 W' Z# M9 {3 h+ X3 ?+ H$ C' A3 m
StringReplace, full_path, full_path, `r, , all" k: L J7 Y& R `3 Q% O6 u- U( Y
IfInString full_path, \
( v5 z: Z. {% b& r. [4 t5 X {
' `% F0 A+ J7 P Run, cmd /K cd /D “%full_path%”- g5 e. E) f3 Y) n* X* S+ h: g
}" E2 }% j: l# D. c3 M$ g
else( o0 R) \$ t! V
{7 m0 C* q, y% {# N. l9 n- _
Run, cmd /K cd /D “C:\ ”
+ \6 k9 x* q: I9 ^$ y }
! |& Q A+ e+ o }
: `. l& ~0 l9 x+ r6 {9 I8 n/ u 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
8 G3 x0 d; e6 L* I 这段小代码肯能有两个你需要修改的地方
3 q+ J( }/ @' j4 O- K' `2 t& N; n7 x 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键/ m, _+ V' C; I3 ^& H
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “' y. M# U7 x$ b7 g
|