此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。+ c8 V5 e4 z- h
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。3 n0 f4 r" x* U* G5 q/ n
方式一:
' [, b* H5 Z: _: s2 h7 @ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
) u7 h- C, q4 R" X; _ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
, U; i4 [# W+ [; s) l5 o HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! n" B/ f8 d3 F' T' I 方式二:
+ V' V- L+ c+ L 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
| w: t" }: }1 y! j SetTitleMatchMode RegEx
! K% @) D9 ~. M3 O; o return( c. m7 f8 u. w* x. v; G
; Stuff to do when Windows Explorer is open; W2 c0 Y, Z( S, J1 t
;
( N, a" _& B0 g- L- {, Z; p0 @ #IfWinActive ahk_class ExploreWClass|CabinetWClass. S0 o; W& ^- E8 [
; open ‘cmd’ in the current directory5 ^# e6 {" @3 k+ {) I3 `/ n
;* x# W9 g3 p, j. U: V
#c::
6 @. w( J/ x( n0 [; Z/ y5 |6 |/ C OpenCmdInCurrent()
4 o4 A) g- p) K J" T# q return5 }* f9 Y/ B. p+ S
#IfWinActive* l; j/ u2 O" n1 ~# m* c/ {
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
, u% f% J4 R9 H& E3 \3 V; @4 o- ^' l9 [ ; Note: expecting to be run when the active window is Explorer.$ c" Q* P- D$ W- E& Q5 j, R
;7 B: x; }! O0 _- Q# q
OpenCmdInCurrent()
* k- `1 B% s4 a% r' d4 C6 n {
) h* O% R- x. ^/ P, i$ x E$ s ; This is required to get the full path of the file from the address bar( `( p8 X6 A% l7 N
WinGetText, full_path, A
+ A {8 @% ^+ N ; Split on newline (`n)
7 K: Z) X0 w. K3 ~$ T StringSplit, word_array, full_path, `n
8 h0 c( r1 C, f1 r' m/ _ ; Take the first element from the array
' y5 Q& C, d9 J- }# {6 x/ K z full_path = %word_array1%4 \& F6 l2 L. f+ d! C4 a- T
; strip to bare address, F% _8 M+ Y3 j; x' x
full_path := RegExReplace(full_path, “地址: “, “”)
' U7 {! b2 C, c/ w( H, j/ s% V* | ; Just in case – remove all carriage returns (`r)
3 o) `7 w6 Z$ z/ t5 v# { StringReplace, full_path, full_path, `r, , all* K9 U& o3 Q; T
IfInString full_path, \
: L( G$ e8 @4 u; d, M {
! I5 Z; _! X1 K1 P2 o' o Run, cmd /K cd /D “%full_path%”) u, V, z( M' I# Z, k. T5 u' T
}
% P7 }- H! j' I8 v# @1 P: c else5 G0 D* o$ M- m# W9 N2 s
{( i4 z k. J, n' o
Run, cmd /K cd /D “C:\ ”4 b! V$ p2 U' A/ Q" G6 \
}
' ^3 f2 I5 Y' `) @* \ } [; G, s6 f% B9 X2 x4 F3 N
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 | A$ Y% T- s% N 这段小代码肯能有两个你需要修改的地方
' p; |$ f9 [4 x 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
, q3 Y% }! Z/ D5 M# k2 Y' @ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
! ]! }9 b& ?( N6 g* K, y- y |