此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
! {6 S) m$ d! Q% N7 u w$ o 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。; J2 M, U2 g. T- j
方式一:
' k( c! @7 P/ a3 j6 ` 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表," G5 t' ^1 s8 G2 r e" x0 J
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; j* l& B& a8 K HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 b* {: t2 `5 ^# c8 j3 K0 A) t
方式二:
/ x, h" v5 \/ r: d* D2 U* F 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- c( A9 m" |) K4 V SetTitleMatchMode RegEx
- X( X h9 O1 |3 B# _$ v8 J return8 u, `# u" x/ p
; Stuff to do when Windows Explorer is open* l* Z1 d( b: L {
;3 w8 t1 b% E6 F5 a6 s2 c
#IfWinActive ahk_class ExploreWClass|CabinetWClass
2 p! v- Y$ s9 L* q9 ~* H/ l! P: h ; open ‘cmd’ in the current directory+ c+ v' F; o( e' H6 N& L- ]
;
1 l2 {4 G, w7 J #c::3 [1 b( C' d+ ?( V6 ]4 ]5 R
OpenCmdInCurrent()
: g: ~: ~; U, r' c5 o# k return
: \8 F/ ^4 N& l# k* W% Y+ {: X #IfWinActive/ c2 s7 M. V9 l |
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
6 _* H! E4 I3 h ; Note: expecting to be run when the active window is Explorer.8 M( O0 c7 J6 O0 x& C: B
;
; w8 \( B% D& N' ?9 T. Y) V7 ^2 s OpenCmdInCurrent()5 l% W$ M" n! G' R9 H: E, r. j
{
. b' A$ w" p" ~4 C7 q1 Y ; This is required to get the full path of the file from the address bar; F! j5 q; c V/ I
WinGetText, full_path, A* e) f6 o- Q! H' M% D4 C
; Split on newline (`n)( q$ @) C$ P3 b7 R
StringSplit, word_array, full_path, `n/ j2 k) ~& H" F( `4 q
; Take the first element from the array
4 j" ?# Q/ \! }1 n7 m full_path = %word_array1%
3 T% B( i8 l" @6 \6 B ; strip to bare address5 ~0 i: X8 L0 y6 g" {
full_path := RegExReplace(full_path, “地址: “, “”)! W+ M* q' A/ L& t
; Just in case – remove all carriage returns (`r)& r# m$ v) @0 W2 n7 h; _
StringReplace, full_path, full_path, `r, , all I$ u9 q. N9 {. W
IfInString full_path, \
R L3 p9 a7 I {+ G: o' b3 K6 s& W
Run, cmd /K cd /D “%full_path%”
? a3 E- G6 d. X" k* y }
' P3 W j$ M- y! ]) i' D else9 Z1 S: s7 G. c6 t- D
{5 g6 |# \5 L6 X( i' _# A: _% T
Run, cmd /K cd /D “C:\ ”2 W* ^2 g; h+ f, @4 I* t: w4 ~
}( T; P. V+ H! m
}# |) n* Y) l0 W& ^0 ?
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 P6 A$ U; _# z+ U2 q 这段小代码肯能有两个你需要修改的地方0 u& d1 f+ ]" @
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
% P' ^' J/ ?+ x5 M* f m( D 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “& R* R( K/ D0 I. z, `0 Q
|