此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- n) x' O# @: H: Z w 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 Y& \" V/ C h
方式一:' W4 c R: \" G9 C/ N; z, r1 s
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
0 l+ K: e; X/ {; w% q7 m 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和$ u r) L3 u$ p \, c* z
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。; D" @# a% v6 [: _7 Y4 G
方式二:' A" D. {% ]. |3 X: [# W# Q
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
) c$ A' a% a: O3 F; x SetTitleMatchMode RegEx
' z* @4 K& V' S3 s return
9 H$ n4 p0 ?* j$ I ; Stuff to do when Windows Explorer is open
6 `5 S, Z$ Y- L6 s* ?. d- ?" n ;0 ^& G% r/ E1 b/ y( J/ J( _( g
#IfWinActive ahk_class ExploreWClass|CabinetWClass$ X* h) W% V, e( ^
; open ‘cmd’ in the current directory
5 t* Y O' D4 J& q9 [ ;
$ o/ D/ N: l3 j0 O- B9 b: b4 Q #c::" }( S1 D u8 z# D4 P2 c" {
OpenCmdInCurrent()
! R6 K) o9 p: @5 |$ A4 f) D return; [+ y+ Z* g: m2 L
#IfWinActive
' p, {2 f' n' `4 T% z ; Opens the command shell ‘cmd’ in the directory browsed in Explorer." `+ m, k2 |. O! w: T
; Note: expecting to be run when the active window is Explorer.$ w. d$ U2 I4 E
;- j7 F$ X; w* Q; j/ \
OpenCmdInCurrent()5 T6 \" ]9 W9 d) K3 @+ }6 f
{$ P1 k# p; A% H. \
; This is required to get the full path of the file from the address bar
0 l) P( N! y1 b" } WinGetText, full_path, A0 W7 s9 |/ O1 ^0 d
; Split on newline (`n)6 B' ^% Q% X1 J. e! ]; \
StringSplit, word_array, full_path, `n
( u( [3 U8 S/ {/ j ; Take the first element from the array
5 J/ S% R5 T7 |" m! L& D+ S full_path = %word_array1%, w0 E7 V* ?3 |- \, U& V$ F
; strip to bare address
0 P# i4 r' {% o- f$ b% M. U full_path := RegExReplace(full_path, “地址: “, “”)
: n! N' v C. K8 v ; Just in case – remove all carriage returns (`r)* V% P0 n6 M9 w9 V m/ s/ G
StringReplace, full_path, full_path, `r, , all+ O8 l2 O' o$ B# D. ~7 T
IfInString full_path, \
8 V" w; Q# C; |$ w7 E+ B {" P- U( r3 h; Z0 }# v/ M. _* H
Run, cmd /K cd /D “%full_path%”, Q5 a' u& X2 `4 G- L' b2 D2 I9 e
}" c' z9 Z1 I: D" M: p3 P
else2 O" b% k: r# g6 A& ^4 d
{
. _9 j1 N5 F/ B2 v8 | Run, cmd /K cd /D “C:\ ”$ m# O" M* ]& O" T) q8 v. ~
}/ u/ F0 m( c& N; {
}
4 u! A# O% w Y8 } 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。: y$ h& X$ [* `5 e- ?& f
这段小代码肯能有两个你需要修改的地方: r1 Q6 w+ I; d) ^+ q
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
, l9 J7 x$ J# a1 r- l/ X 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, e, w; s8 W9 n: k
|