此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
& b7 g7 r) h9 [ c( J' R 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: f/ K& F v2 M# S$ A4 }
方式一:% m2 ^2 Z8 e! ?- B5 q# {, {) u
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
, B' J! n; V: ? 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; [7 @2 {; d; }$ P; d HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ a+ G8 f* R4 y* `4 U8 d 方式二:4 U% M" T) P1 |% b6 P3 Z7 u4 n4 u
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
3 I& ^7 A+ R4 ^4 r( A SetTitleMatchMode RegEx
2 u- x" i: _7 P* \" c return" ~9 o: b- T7 o0 G! D+ I2 r K* K
; Stuff to do when Windows Explorer is open% l2 s$ O# p; K) T: i! |3 W
;
: N0 v# l4 O& k4 x #IfWinActive ahk_class ExploreWClass|CabinetWClass' K. x$ l' l" u; U! d
; open ‘cmd’ in the current directory0 U9 _$ A6 m; r# E
;1 Y9 c7 J3 F, j* c( z0 J* ]9 H* ^) c
#c::- m; W ~7 G0 {% i( T( e
OpenCmdInCurrent()) K% D4 E; O* R" a# ~! d: q
return
~% A) U/ b& @& {( @( j+ s #IfWinActive/ C5 w' q) D8 n. \0 N$ D5 T- E+ F4 S# b
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.& G; y$ L; ?- K" A7 f6 \6 a
; Note: expecting to be run when the active window is Explorer.
D6 K0 u7 X' Y6 j V" j ;
. B; W: S, t/ h& L* @7 } OpenCmdInCurrent()/ U& ] ^' M5 Z5 H* m$ H
{
# G; I! Q0 s( g f ; This is required to get the full path of the file from the address bar. e# u* J5 s k9 r1 b0 Q' N% B
WinGetText, full_path, A
6 o: R ?- l! n* O ; Split on newline (`n)
: K, d; n1 i3 G3 q7 j3 @ StringSplit, word_array, full_path, `n( Y( [* b; _' n4 ^3 w4 ]
; Take the first element from the array
! ~: c4 H, a3 B w) x full_path = %word_array1%
" A3 P% p* T' _* k% t ; strip to bare address' y9 w5 K: b( @% f& R1 Z
full_path := RegExReplace(full_path, “地址: “, “”)5 {' B7 J( y. j6 a
; Just in case – remove all carriage returns (`r)
7 }. s. y- z0 U! q1 [; \$ C, T StringReplace, full_path, full_path, `r, , all4 _7 m% n- G) b4 ~9 I/ N
IfInString full_path, \
& _) q5 j4 b6 H1 [ {( T" @" M4 C% p4 ~3 m4 D3 X: E
Run, cmd /K cd /D “%full_path%”
0 H# }9 f* T1 W; s! @6 N0 g }
3 D0 ?- N+ R3 r! V$ U8 o" ~) r% H n4 e else, [) b7 d+ u. A) S; u
{
$ j& C, E( l* A3 x8 z4 h: @) b v Run, cmd /K cd /D “C:\ ”2 S/ A; \1 j6 D+ {% z
}
* i& q% Q2 l1 F' ? }
: s7 a L$ h% z" |+ |) C% S 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。5 K% J, x" b% y- i/ ? U: }3 H: i
这段小代码肯能有两个你需要修改的地方
2 ^, {" q+ h" |5 q# b 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键" R$ y* g+ B6 l: q: l
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “$ B7 Q7 g2 }! {9 Y/ u7 x) t! Y
|