此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。1 u% g3 n$ W3 E5 L9 X7 {
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
* E( L& G" a, m O 方式一:0 |/ k! ?6 A' W+ N9 z! S# E7 h& [
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
2 c, h: O# z5 R# r# } 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
. z4 @! P; E) H, p r HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
% A- W8 n$ W1 f9 ` 方式二: @( v- b; r9 Q! |
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:' I: G% \. @& |( f! R
SetTitleMatchMode RegEx
! o' I% \3 F o5 ?9 d8 C return
- G( G5 d3 s3 f ; Stuff to do when Windows Explorer is open
3 M$ \( m6 b- ^: s3 r. y ;
- p) Q6 c7 l: v; \" W #IfWinActive ahk_class ExploreWClass|CabinetWClass
0 s- h6 V# h: Y+ s2 q( F" w ; open ‘cmd’ in the current directory
2 v8 x, T9 [7 j( K5 V ;
8 J" @9 Z, z1 r! {; L* ]8 W$ o+ c #c::& p2 H/ I l V T. G
OpenCmdInCurrent()0 R; b, n, |" x1 r, K% g
return9 c h# f6 @( l7 H
#IfWinActive
1 [* }& O7 W2 [* i4 u; i ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
]* M& O- i! J* x. I: @0 [$ S ; Note: expecting to be run when the active window is Explorer.
2 N$ Z4 w1 ]8 h' w% j0 b- G ;. G! ^" [; Y" j5 f& k
OpenCmdInCurrent()0 N; }& ]. J5 u
{6 K' X3 v; j8 H+ i, X/ y% J" C
; This is required to get the full path of the file from the address bar, s7 |) g4 J; @9 S# v$ T
WinGetText, full_path, A$ m- q) [4 H+ e& i7 B& X
; Split on newline (`n)! U& p# ~$ g8 ~+ Q! l
StringSplit, word_array, full_path, `n
" ?- a( n( R. N6 ?+ n. ^& G ; Take the first element from the array
- ^ ?1 V+ O; X3 k+ r full_path = %word_array1%
5 w7 I' e6 I6 v5 v3 ^6 I/ W; f ; strip to bare address. B) s- y7 h: C9 i
full_path := RegExReplace(full_path, “地址: “, “”), m8 O4 ~# Q& d( b
; Just in case – remove all carriage returns (`r)
: i4 l1 W+ k' \! b- u2 ? StringReplace, full_path, full_path, `r, , all l5 @. S" P$ e. p3 u' j
IfInString full_path, \
( `; f, G6 M! Y+ W! D( e, G {, V# _" D# F2 V
Run, cmd /K cd /D “%full_path%”
7 l; P, u# _( s4 K" F/ Y4 x }5 u4 @( `. d1 K
else( i6 n- g9 ^ W, |, D
{
7 ^7 a5 [ ^3 \' ~4 _3 ] Run, cmd /K cd /D “C:\ ”
6 {5 a, Q+ } F8 ^ }
& ~# }0 H; \4 e; S; B4 i }9 ]) T+ Z/ f- p0 d8 o' e
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。2 G0 _( s8 T5 ~
这段小代码肯能有两个你需要修改的地方, S9 x6 r. ~* O" H. b8 h
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键# Y1 |& L: i. S4 N
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “4 a8 b2 Q! N! L A' J! }
|