此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
) j* U- O. b2 z" b$ Z 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
2 C. o' r% z9 C X3 S3 a | 方式一:
( g4 A" [& T' l9 p 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
& b! Z* d! l) j 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和1 M* X8 Y* A- w; M3 D* L
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。( e! H0 s, s" `7 k2 n
方式二:
1 T r; d9 X5 o A3 ` 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:8 K: y1 h4 r7 W) m; ?
SetTitleMatchMode RegEx
- i' C# o2 ]( M1 I0 [0 C7 \) O return$ _1 A& V5 D: Y. d5 _! o+ d! Z* G
; Stuff to do when Windows Explorer is open5 z& K+ v: K: O8 L5 H
;* Z0 M& b$ E3 X# A: i6 X
#IfWinActive ahk_class ExploreWClass|CabinetWClass
! T" c+ t8 u7 A, M ; open ‘cmd’ in the current directory
# @: F# l4 S/ ^/ l1 p: Z" |8 E ;
" R; G T* h: U2 ~2 X( P3 b #c::
7 A3 e7 f ^- v! U5 y OpenCmdInCurrent()
, t3 l) _2 z, b2 j return3 M! I$ ?4 T0 \6 a. F# r
#IfWinActive/ F( ~0 w0 i0 Q3 }
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
$ ?- R* e$ ]' b9 C, F) {. r ; Note: expecting to be run when the active window is Explorer. {8 S0 e' w4 z$ ^; G1 \* J% s# Y
;) c1 [+ {( v& G/ G. ~4 n
OpenCmdInCurrent()( A; z" R, P A
{& a6 k) K) ^( b+ C- t
; This is required to get the full path of the file from the address bar2 z7 i( h: O) p! E0 x3 N! [
WinGetText, full_path, A
0 }4 D3 [/ Y* G* J' D ; Split on newline (`n)1 u6 N* u2 ^# A. c" C/ E) b Q
StringSplit, word_array, full_path, `n1 d" O0 X; l3 V5 w' T' ]
; Take the first element from the array
- O- \" {& o& ?1 g# Q8 n1 W full_path = %word_array1%
. y0 v& b9 L" |' j0 u1 K ; strip to bare address& `' d I c! _+ h( U
full_path := RegExReplace(full_path, “地址: “, “”)! R2 @! w) v) k( S: ]
; Just in case – remove all carriage returns (`r)" P/ K+ N U7 f6 g0 L1 ?+ e
StringReplace, full_path, full_path, `r, , all3 | M P1 t9 @! }. Q8 d
IfInString full_path, \
% T$ P2 L4 B, ^. ~! c/ a3 V {; Z1 |& o' F: S
Run, cmd /K cd /D “%full_path%”
+ D2 j" g. X& @3 P% u& U2 q }- D5 k8 k6 c- ^' b9 a* i- Y u
else
0 L% D6 k, `* B {. b S; d. }4 X- V4 _4 u4 Q
Run, cmd /K cd /D “C:\ ”
$ d# T5 l- T1 a4 c" F }' S# ^, p2 p. _: k+ |
}
. i& O! P( I. W* H0 I v 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。. y6 o+ D% ~3 _5 Y8 [& m2 @0 |
这段小代码肯能有两个你需要修改的地方$ @& z4 H, j, B) n$ s1 i1 Z U W8 A+ {/ s
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
: M- a# ]' ~; n1 } 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 C! H7 F" i, s1 h) a2 F) v; J |