此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; n- S" C: `! ]
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
5 p+ h. A. @9 p 方式一:0 l+ u8 A8 ^ r# Y& D+ t
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,6 z( N: W; x& C1 a- P0 K/ I
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
$ Z5 H+ ?6 `% G% l' a HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
: ?% l4 \+ j! T0 @ 方式二:1 z# E5 p' \% r$ K
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:- ^/ l- y& q3 W7 e; c7 Y
SetTitleMatchMode RegEx
% @$ ~4 m* r$ I% l3 b! R2 I return
! O, J2 {, G- ]! i9 ? ; Stuff to do when Windows Explorer is open
( w- `1 n. d" L) Y J* J' K ;$ }$ h% d9 Q4 R) G3 F* X8 m6 c
#IfWinActive ahk_class ExploreWClass|CabinetWClass
/ `2 h3 }! y: P4 i ; open ‘cmd’ in the current directory
9 M; k) f1 r* ~ M ;+ f, V5 B g M1 y. c1 ?& S4 d a
#c::& m; C. R3 C% h* _1 \
OpenCmdInCurrent()
8 j0 R1 M6 U3 Q+ f# \/ o# f return
( L6 f8 ?! ~$ [- l$ w7 ~: X+ r- @1 K #IfWinActive
& T3 V! L1 ~4 s! ? g ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 ]/ D( f8 p8 c8 @
; Note: expecting to be run when the active window is Explorer.9 Y+ i M; H5 l9 o5 S) X- B6 C/ E6 h
;" W( V1 T! R: W
OpenCmdInCurrent()
! t& T+ b! D1 M! U# w4 B0 f {( T, q% z) A A7 ?3 W3 U; R
; This is required to get the full path of the file from the address bar2 g, n5 |$ t# R2 _9 s
WinGetText, full_path, A
6 k7 C7 `9 a" Q O: C$ T) t0 Z ; Split on newline (`n)5 S# l" @9 z! H# ]0 j3 P0 S2 I
StringSplit, word_array, full_path, `n
0 L) v6 b, p7 ~1 w9 G ; Take the first element from the array
7 [5 [7 C9 C* ?& T full_path = %word_array1%
9 R( ] d* F4 u, q; p0 [3 s6 | ; strip to bare address& X G8 h, f! H. y! Y
full_path := RegExReplace(full_path, “地址: “, “”)
( J3 Y, p8 Y3 t ; Just in case – remove all carriage returns (`r)
# p* V* x+ x s' S+ k+ _5 G- @ StringReplace, full_path, full_path, `r, , all
6 y- `/ ~* z5 `" | O: i$ m IfInString full_path, \2 r) A* A- v) n! `! d
{
6 U; }: _9 T7 a! L5 B: v+ Q Run, cmd /K cd /D “%full_path%”
( J' Y: S5 y: L8 R) R }6 e, e; ]+ C/ m$ F
else, Y1 d3 C0 A% K/ ^: a% _# L# Y
{% G6 W( F# I5 G
Run, cmd /K cd /D “C:\ ”
4 l8 M: p) T; K. J- w/ N3 A }
5 x$ i9 g( i$ W4 h U/ s/ j3 H }
, L$ n, ]& @ I7 M' m 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。+ c( x) u7 }6 D% L( b/ m% z* v0 y. ^
这段小代码肯能有两个你需要修改的地方4 F, n6 p o3 u' \, V) _5 g* ]7 n4 f
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 v( U1 g M2 a" E4 f0 Z
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “3 p } d; q7 P7 z3 {
|