此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。: [9 i* a: {) b* a2 b
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。; Q9 L7 V2 }: z+ n* T
方式一:
: V# T& e6 p2 w& ?1 v) z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
1 }0 E5 g; ~9 P& f4 \4 d: C1 F! K 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: ~ l" D9 b4 ~7 V
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
9 S, {5 x9 R4 @! R% a$ m+ U 方式二:" Q- a5 E/ |7 x" @4 L& `
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: T" F7 N% N* y0 I1 k( ^
SetTitleMatchMode RegEx) E X% H( b2 B' \3 z
return& Y* G. n+ ^, `) S
; Stuff to do when Windows Explorer is open W' O1 \# M7 v, Z9 b! I2 ~
;* f+ Q, L9 d( V4 E) k7 f
#IfWinActive ahk_class ExploreWClass|CabinetWClass
( v$ B2 X# A a5 @$ Y" a ; open ‘cmd’ in the current directory
" L) W/ H' [/ d* d P ;
/ y0 ^' n' R$ J# {& D0 \ #c::
6 N/ }% \6 F6 w1 l; i; K( b# { OpenCmdInCurrent()
6 E& I7 ]2 O) ]7 L) ]* C4 C return: ^7 {' G2 w |7 ~7 Y! f S
#IfWinActive& {. G$ h+ f& R0 H' z9 C1 F, v
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
/ f, Z5 [! q3 b" A4 w4 N ^ ; Note: expecting to be run when the active window is Explorer.
8 L. N6 d" v7 D/ U/ P8 P. S ;- n- Q( s3 A, r/ z7 g
OpenCmdInCurrent()
& q4 @4 A( B" r: s! a. o {
9 ~ Y, c; L9 O. U& Z ; This is required to get the full path of the file from the address bar4 u8 a6 R& y" l) i
WinGetText, full_path, A: T/ k9 P9 ~2 i7 W4 E" E: K
; Split on newline (`n)
Q) I% Z' D7 l4 D StringSplit, word_array, full_path, `n6 n' T. E3 H% M1 L4 j# |
; Take the first element from the array$ T& R2 l6 |! c3 W. \4 c
full_path = %word_array1%
% z: i$ ?/ V7 Y ; strip to bare address
5 O! O) z5 g" N- @* Y2 X full_path := RegExReplace(full_path, “地址: “, “”)
9 O& N7 r7 v+ b8 L+ y) A ; Just in case – remove all carriage returns (`r)3 ^! B, `6 H: z3 e/ @" |" C& u# A
StringReplace, full_path, full_path, `r, , all
x2 |5 k1 N) _+ L7 T1 a( H3 G IfInString full_path, \
: @+ O- o0 Y, G$ J, R8 N. K3 a2 O {
( K2 a( ]1 n! T Run, cmd /K cd /D “%full_path%”
. U2 c( Q0 m* B% s }
" ?, c6 x) ^7 Z) u else
0 s+ |+ U) n& V& Q& Q0 }& n( l; P& u8 o. X {
" ^9 \3 C' `$ e Run, cmd /K cd /D “C:\ ”
$ B! o$ d+ K" Q6 W: `) i" K% S1 ] }
, t5 b: L. k: K& W" C# N* `$ O, p }
" b! ~* S! @3 @4 ?, Z3 \1 s2 D 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
4 G1 Z/ X# T- Y3 g8 u6 C 这段小代码肯能有两个你需要修改的地方0 A! N) {: Z1 w- r" h; ~- f9 h- k
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' J( u k/ `: W/ U! r9 S 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “: P0 _6 U; ]7 l3 B' q
|