此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。$ d3 b( j% O; J- d: ]
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 ]7 v! d* I1 t
方式一:& S( `" O5 E1 A8 g6 n" Y
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
) P! t5 v0 @7 f! x- [, S 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 f. Z* v! A- b+ t5 E2 c; N3 [ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。' b# L2 v6 o. l, l* `
方式二:& q. b. ?' y9 g# d ?
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
8 h; U( q/ z0 {1 n* Z SetTitleMatchMode RegEx
- ^- s; e- @9 y |* o" ?# a return2 C2 D! L! R% f+ z$ {+ o) s/ C; G
; Stuff to do when Windows Explorer is open
% R3 B6 ?* X3 o4 i$ Y7 G ;* F0 ^+ d) U$ ]
#IfWinActive ahk_class ExploreWClass|CabinetWClass3 a% X* [: R9 ?3 u2 v2 \7 g9 R
; open ‘cmd’ in the current directory/ z* b- x2 l" d
;
: X- y5 n4 I! y6 k" Q1 a f #c::
, F* \9 p; |2 _ OpenCmdInCurrent()/ l. |* L# L) K( ?2 e/ x
return
! @$ {) S$ x8 t. T" p5 t& Z #IfWinActive
. C( @6 j: \& U8 O% h* M/ G ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.( h5 P3 Y( \2 N k6 d" K
; Note: expecting to be run when the active window is Explorer.2 t9 P& O6 F( ^1 R Q6 b; h. Z0 y
;% b- U% `. L# G8 g) c0 K& ~1 d' x
OpenCmdInCurrent()
7 J3 j. h# Z2 o0 ^8 p1 k5 j% I" Y$ s/ T {
, w+ O y' b2 q& B ; This is required to get the full path of the file from the address bar0 d: k9 c% ~/ y( J3 b4 a. J4 v4 X
WinGetText, full_path, A
s( U% {+ U- c! V4 V5 U/ P ; Split on newline (`n)
% f9 n5 H: n8 b! F4 [$ @ StringSplit, word_array, full_path, `n7 j: D% H3 \; S8 G
; Take the first element from the array* T* _8 T" K2 g3 u* C0 N: D9 _
full_path = %word_array1%+ G3 O9 h1 g' S. p2 z/ d$ C7 E
; strip to bare address+ f/ L$ } R6 P) i+ {
full_path := RegExReplace(full_path, “地址: “, “”)
+ V8 ^$ }- V- L! v ; Just in case – remove all carriage returns (`r)2 ]* Y8 b6 y- e( E( E0 k
StringReplace, full_path, full_path, `r, , all$ U( a1 C/ R7 K2 L$ H% C' D
IfInString full_path, \1 N7 Y- n- ?' ^! y! s: t
{
, J, d; i1 t& ? Run, cmd /K cd /D “%full_path%”
- t, Z8 O! |3 }* t M# {8 v }
r( Y3 h8 P/ _7 x9 ]- j% q% W else; N2 t: v' w p6 k' W
{
7 g: N4 k) y$ h Run, cmd /K cd /D “C:\ ”$ _5 x' V( K4 A0 Y3 |
}
- E4 `- j5 h1 a& N' y) Y6 X }- l/ {5 [- |. I- b# A+ g t
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 \/ n7 W ?. _: V 这段小代码肯能有两个你需要修改的地方! @% R2 @" h( ?0 P
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键 W6 v1 a; [$ [" `( a
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
" s, s- E6 H) N2 } |