此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。0 G0 W+ R. s- K/ |
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: E- y0 |! O9 W5 f: a: }$ _
方式一:0 q, U+ i' B* s3 r
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
* @: T& v7 c3 t2 X4 e0 R$ T8 _ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和0 j$ M" H1 D2 S; Z$ C
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
% d8 L1 k9 V/ z1 e 方式二:
' E% ]7 W. n: r7 `6 f! {2 N 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
6 X; R0 W& y4 } SetTitleMatchMode RegEx
; f* V+ W8 x3 V: |: s7 c# i return
3 u/ q) M% l( I7 r9 l. p: l5 g3 G ; Stuff to do when Windows Explorer is open
# m& Y9 g, t( e9 ]) X3 F6 o- J ;# u2 A; I; x$ h( W. |
#IfWinActive ahk_class ExploreWClass|CabinetWClass0 ^0 b7 T" h/ d. u0 |
; open ‘cmd’ in the current directory
8 E% S& p& J `, d ;: F9 S8 @) r& B* {! H
#c::
' r- ~" L2 E, c/ g OpenCmdInCurrent()
( @- Q. M: f3 i* `' w( c return3 I f, j8 W0 @* ?
#IfWinActive; I: r3 y% L+ F! P! E h
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
3 G7 W9 K* g- A: A- a ; Note: expecting to be run when the active window is Explorer.
/ z# w( [: D( N0 ], U+ a- G ;8 ?8 l$ v5 n# \6 F$ {
OpenCmdInCurrent()7 h3 k$ X4 k/ c7 [& B4 ?+ V
{
& a& K' G7 k4 |. n ; This is required to get the full path of the file from the address bar
6 b$ O( J- G9 L% J. d; ~8 |5 Q( b WinGetText, full_path, A
0 n, q) _ V0 S" j0 a7 T7 i) N3 a ; Split on newline (`n)( _& J% o2 U3 {! t4 P1 |" r
StringSplit, word_array, full_path, `n
+ a1 C/ D6 r( x- t3 I4 S0 J ; Take the first element from the array
) `$ l+ f+ d4 w full_path = %word_array1%6 r8 V( }$ Q; l9 } M
; strip to bare address
- l2 Y* [% r6 _5 Z& _ full_path := RegExReplace(full_path, “地址: “, “”)
# {) T6 g& Q4 ]1 u' {2 Z& n. r ; Just in case – remove all carriage returns (`r)
0 a: i* m1 K; C StringReplace, full_path, full_path, `r, , all) y: C6 ^, A% u5 W
IfInString full_path, \
' ?+ @# l: e& b$ ^& o4 W B {( t; d1 [1 j6 C) J. R) C, `
Run, cmd /K cd /D “%full_path%”+ [2 T4 I: q0 w' y, ?* g
}3 J& i; J Z; x- Q \6 }
else8 ~# W1 J& @* H7 \: b O( r
{5 j: Z m3 q+ U4 R; Q0 B
Run, cmd /K cd /D “C:\ ”* R; j+ f# ?$ ^1 _+ V/ R
}. {' B9 K. J+ \7 p0 z
}+ e! }4 E7 ~0 v1 }
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
8 l3 I, i$ N: m2 q: H$ N 这段小代码肯能有两个你需要修改的地方& a7 R/ O6 z; o" b0 _, X3 S* b$ T* i
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
2 v) u1 q* f* k( Y3 F 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “! v; g. o& N$ s7 q/ q
|