此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
8 j3 l1 l- S8 s O# ` `: I9 r 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
" J0 e4 O4 ~0 y 方式一:
" I9 y2 ]! Q% g/ d0 b7 x$ i 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
_, v, R) F% N/ W+ _ d: i3 n1 R 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
$ }2 R+ c( A6 L HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! u& V9 W# H& b6 _) ]% j 方式二:# G* c. V; e1 E! o
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ s: Q0 H( i/ X% @6 m SetTitleMatchMode RegEx+ v+ [# x+ d- d4 }+ u
return
) g/ R2 {6 j* V4 l1 |% w; _4 }% O1 c ; Stuff to do when Windows Explorer is open+ p% n# a$ k2 B+ m4 a2 o, \, y2 q7 w8 b
;
' u% r, E6 e F7 x! _ #IfWinActive ahk_class ExploreWClass|CabinetWClass
* t3 G7 K, Z* k2 o: _ ; open ‘cmd’ in the current directory
: i. B$ E$ `2 u+ S. N9 k ;: ~3 @4 p/ z; v8 K
#c:: l8 |( C. j: a
OpenCmdInCurrent()/ J: h8 C+ E' g( x+ F
return
! ?$ l8 W) M& t #IfWinActive
" t) Z% l( [0 H w ; Opens the command shell ‘cmd’ in the directory browsed in Explorer., G$ N( h. I; u' ]. Y) ?" Z
; Note: expecting to be run when the active window is Explorer.+ ^% B- r: U! i& Y2 Z
;& r0 ^9 ^2 O, `9 p
OpenCmdInCurrent()
. L( L3 Y+ [3 [6 ^1 {* P, A {, W; R& q$ d: S" y% T( u9 U7 f' r0 |
; This is required to get the full path of the file from the address bar
- ^1 ?- E0 u! [7 A' V6 Q2 l WinGetText, full_path, A
3 q4 D. w7 n$ r3 C ; Split on newline (`n)2 q$ L% E& m4 e9 w$ w8 f9 ]
StringSplit, word_array, full_path, `n; B+ |0 I6 D# A" _$ x4 D
; Take the first element from the array! `' M5 N: Y- e4 [# E
full_path = %word_array1%! d! c9 c) h/ W5 ?8 s' Z
; strip to bare address j+ b1 ]: z' _ F, \! P& b
full_path := RegExReplace(full_path, “地址: “, “”)
! b& M) K. j, f& F ; Just in case – remove all carriage returns (`r)
& c: ]) m# t: m. ^ StringReplace, full_path, full_path, `r, , all
: p2 v6 \" I! I O IfInString full_path, \
) ]+ C" d6 |* e8 l. u2 ] {; f5 l0 Y: ?6 v6 E$ s' j5 X
Run, cmd /K cd /D “%full_path%”
& M& `3 o2 l- d7 r# b7 d }9 p, g7 k( }) u+ e+ u l v8 h& r8 ~
else4 s' P" Z7 A5 P7 e" K5 f. l
{
( x# E9 b- l' ^) v V* Z Run, cmd /K cd /D “C:\ ”* C! P5 m/ _- s7 p0 u7 k _) W: ]
}% J/ R( P3 C/ W% Q. v
}
! G: l, ?; X6 ?4 g 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
7 o( ~% l5 ^) ?" S* _ 这段小代码肯能有两个你需要修改的地方
; R; i8 Q- p' j) D& \5 N6 | 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
8 }, Q& z2 s0 Y7 V5 N 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “3 d6 X& K6 B8 U$ L+ U! H
|