此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。. f1 a5 Z% }. w
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
3 K/ |2 d8 x9 p B7 T- ]* T. B4 H 方式一:
& T0 d7 S2 K' F; a( z) o 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% B- u3 C0 H7 o+ \! _ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
: ^( j3 Q9 ?; H2 ~3 d HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。, |- ?: n% x' I
方式二:: v; t& T" ]7 W0 c4 F
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! W- }; b s4 }& N! M# i s' }
SetTitleMatchMode RegEx
7 k5 }7 M6 V" r2 U return" W# Y, V3 X6 a0 {
; Stuff to do when Windows Explorer is open! P9 L9 I+ r* k8 ~7 n
;/ p6 G5 v+ A1 p' z( l) O
#IfWinActive ahk_class ExploreWClass|CabinetWClass
6 o& Q, k4 K9 S2 q9 q1 N6 b ; open ‘cmd’ in the current directory
9 h# B1 M; ~/ f/ u ;5 E" m* o @ ~$ k
#c::
& \) y* m5 m3 d: u OpenCmdInCurrent()
9 D+ Y! R' o% R$ `7 c( r return8 F) ?9 K, Y: g, q2 C. E
#IfWinActive; a' l& I& m1 V
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.9 s5 ]2 p0 J: c3 ~
; Note: expecting to be run when the active window is Explorer.
% b% m/ u# m" y, A ;/ d0 J, x% a1 M
OpenCmdInCurrent()" u [+ ^. o5 o9 M! ]
{; e$ G# S( g1 B5 v w1 X8 c
; This is required to get the full path of the file from the address bar
8 z; i" w1 ^# D- Y& o WinGetText, full_path, A
% d# k2 w& |) y ; Split on newline (`n)2 c+ z' I: ?1 b6 o
StringSplit, word_array, full_path, `n! d# s1 D2 D( ^- J
; Take the first element from the array
8 I1 M% Y6 d) z3 `8 W- x$ f full_path = %word_array1%
9 b. D8 w$ c7 d) ] ; strip to bare address
5 Z4 \+ |( R( n3 G full_path := RegExReplace(full_path, “地址: “, “”)+ q- W) u# o& t: \. {2 N( h! i
; Just in case – remove all carriage returns (`r)0 Z. e/ z' M+ ^6 f+ A
StringReplace, full_path, full_path, `r, , all
7 W. @5 @2 u* E" I6 t9 j IfInString full_path, \/ o- ]8 b3 X6 f2 P7 x+ b
{
, [* c c) |# t( {4 c$ j0 G$ _ Run, cmd /K cd /D “%full_path%”
. R& `2 h! b# o" K0 s }. h- `, m9 x! l' k" L
else' o$ Y# {6 [- m4 s
{; S* o5 Z( G7 C$ U/ m7 t' A
Run, cmd /K cd /D “C:\ ”
) d, m+ ^3 t3 |) ^ }9 e4 Q. H, E _$ H8 Y% v
}
& v" l4 o% }) a# X* Y 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
& j: h- H2 [9 Y- V5 d4 r9 S 这段小代码肯能有两个你需要修改的地方
( f |, i2 Q) z* @# G: H 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键# K6 g f( K4 p& D2 j
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
! h8 s& p4 c% X$ o( n# z% k" m) C/ Z; Q% O |