此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' D3 J! R# f7 y% o& i) q
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。+ e2 h! j: u( W
方式一:8 U3 |. x7 |) C: `. \% w
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,4 K, _5 p$ o* g0 C; ]# f5 s! P
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
+ w0 B" c. d9 @+ Z1 A m# m HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
' y) ~4 Q* X+ A; f% Q. m2 Z 方式二:
: G) W" H& t7 W3 I- C 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
. D6 ?: d7 J* `1 K V SetTitleMatchMode RegEx9 T* t: e3 `# U
return
5 `* n2 m) j1 Y7 e0 u2 y& W) L6 k ; Stuff to do when Windows Explorer is open
1 s0 |+ t3 k1 x3 j4 L6 f t ;* y% S6 E+ G# r/ A) c# F
#IfWinActive ahk_class ExploreWClass|CabinetWClass
# V( P# I/ w2 H L ; open ‘cmd’ in the current directory
: D, W+ H, h. |% }+ Z( v ;: C# L( }! |. i& m9 R1 U7 K2 _
#c::8 E4 [ Z n# ?8 t5 m" L- k, Z7 @
OpenCmdInCurrent()
1 F- T8 c8 v$ @8 X return8 W3 q, X5 H% d0 { d, a- S1 W) R
#IfWinActive4 p' ?7 Z5 M/ _- r
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
8 @+ \# F) }3 Y9 v; W. S7 \2 Z ; Note: expecting to be run when the active window is Explorer.; \' x1 I# `) l1 H6 \9 t
;
' P6 k0 y _8 z# Q# c6 l OpenCmdInCurrent()' `6 Z1 H2 Y3 E+ C- @/ C
{2 w# z T1 t c% C) R8 T
; This is required to get the full path of the file from the address bar
, d6 A$ a3 l( D }& E' M" {% H; o WinGetText, full_path, A
: N+ g9 @ y; E8 f. K9 W ; Split on newline (`n)
. ?0 J( y( h* q/ ?1 c0 c4 X StringSplit, word_array, full_path, `n+ `# w; g, X0 h+ H, X! P& n
; Take the first element from the array
! Y# q; y p3 Q& R9 @ full_path = %word_array1%6 }, d% [+ H) o
; strip to bare address
8 `" N B8 \- x6 } full_path := RegExReplace(full_path, “地址: “, “”)2 z+ w0 ^9 g: V1 p8 T
; Just in case – remove all carriage returns (`r)& W& U1 ?& M, t& \/ O
StringReplace, full_path, full_path, `r, , all
. O$ R1 I* ~- L( _& }+ x3 B9 ~& W IfInString full_path, \- n y' h4 T' z
{
8 @6 ]0 h3 M7 x, M: |7 I Run, cmd /K cd /D “%full_path%”) x0 F& m/ b& h
}
+ f. j5 M; B, Y$ H; v else9 w/ H9 V8 L* v+ p
{0 i0 |0 ?5 H2 g2 `
Run, cmd /K cd /D “C:\ ”
6 A# m. a4 K! n& r: p }
9 H8 k! ^( s9 ^& U& A" ~8 e }
' G; e5 r6 {( }3 f5 v; d 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
1 g5 D) Z( X* ^- l4 u9 [8 Y0 X 这段小代码肯能有两个你需要修改的地方
! }7 w5 H! E* H' M 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键( k4 Y4 N/ \8 e/ G* D
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
1 p: o% T+ h! d1 } T8 d |