此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 L7 _$ h0 K. |: u( F" a- B 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
/ l6 s* e6 v3 D0 d; `. z' Z 方式一:
3 y! X7 n. {3 Z/ u 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* }; [: r4 y2 j. `+ ~
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 V6 b2 q7 T" Z
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。$ K7 @. F. X" N
方式二: p4 l) R" f( V$ e
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:4 E! b* M! \9 I$ j, N% z. N6 o( G
SetTitleMatchMode RegEx- e' N) Y; ^2 t B7 I
return
% |$ d% Z" R( Y! h A ; Stuff to do when Windows Explorer is open8 [) S+ r9 @; x. H9 o$ {) w: u p. M
;4 i6 b; ]4 I- t6 T% E7 r
#IfWinActive ahk_class ExploreWClass|CabinetWClass' N" S2 k3 H6 s( I$ M" c p
; open ‘cmd’ in the current directory
* {/ Q3 G: u7 ]9 S( A- V ;( Q4 E+ ^! [8 _# k1 b4 ^- G
#c::4 L% [- [8 u/ w- k
OpenCmdInCurrent()
8 L6 n7 L3 i/ {: y! V return
9 w+ R! Z9 F7 x6 J" R/ U3 h! b+ f4 R #IfWinActive
7 z+ |& f+ o3 |& s( D ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
4 `: x( S8 }3 C ; Note: expecting to be run when the active window is Explorer.& I* m! a( d- @" u/ e, D" ]9 i
;
W# \+ O2 C4 H3 `" [3 ~ OpenCmdInCurrent()0 }: P# ^0 L; a) ]% U
{7 K- r- b; U" R7 u# ?
; This is required to get the full path of the file from the address bar
. A4 x$ `* g4 x3 Y8 E9 r! n( i WinGetText, full_path, A
' s' ^& J& ?! O ; Split on newline (`n)
1 m2 ?1 r9 ]8 e6 q- n. u4 V StringSplit, word_array, full_path, `n8 \, i+ _# ]/ Y7 w& F+ n( b S
; Take the first element from the array1 @" g' h$ K/ o8 b, L
full_path = %word_array1%
, W$ R' y y+ F6 E# m ; strip to bare address! s( R4 \& A$ b! v V
full_path := RegExReplace(full_path, “地址: “, “”)
; ~! J* @$ @: @0 I2 [ O; w ; Just in case – remove all carriage returns (`r)2 x2 s0 A# d6 r/ a9 ~7 g) V, C
StringReplace, full_path, full_path, `r, , all3 l3 _- ?1 b1 A5 Z
IfInString full_path, \) k. M( L2 }1 f1 [$ F1 Z$ {; |
{
E& ?- u( I% ?6 _$ T Run, cmd /K cd /D “%full_path%”
$ P* _& f9 v+ ^9 P }
; H8 v( Y4 }5 \ else6 O: `4 X! y8 t, E/ e' P& Z
{, Q2 y0 I5 b/ Y k4 H4 b; _
Run, cmd /K cd /D “C:\ ”
8 O8 v7 x- d% v: f# _( A5 G }8 G2 N6 C- G$ V3 y2 D1 G
}
3 Y6 {. w' M: T4 b z1 C& f/ _& y 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
1 L" s% N0 Y6 b2 F. W- X. n F6 D 这段小代码肯能有两个你需要修改的地方$ s5 k! P+ q j: [8 b& m$ X
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
6 K- R- _# v/ \0 ?, p 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “5 @) ]& ~7 x+ z# Z3 s0 ?* y, w$ `
|