此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; z C7 S* l2 O |0 X7 U
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
: Z) k* S: f" e8 K8 d# J7 q1 J 方式一:1 m/ Y) A1 a9 u! k/ r8 s. ~3 B$ Y' b( N
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表, D5 a m1 M$ m$ [0 b! g
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和% F+ L- L1 Y% y. B$ t9 _) K
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 ^3 _6 j+ m9 H6 X& {% w6 L
方式二:
/ g) \. F! I/ U/ O4 q6 o 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
8 u3 L' o* d8 M8 D; s/ p2 j, { SetTitleMatchMode RegEx9 H2 A8 {4 F' S: C- n4 k+ X# G# G
return
5 j9 U9 ~" u7 |5 |: f# N. z$ d, d ; Stuff to do when Windows Explorer is open `# g& n8 X2 r- y
;% n, p! \* m' T* I0 V: J
#IfWinActive ahk_class ExploreWClass|CabinetWClass
p: |9 j4 H" _' M ; open ‘cmd’ in the current directory; L! m3 a- O/ j" C9 g
;
& t6 s! t6 `* [ #c::
0 n" k! G0 H& F& h# A OpenCmdInCurrent()
; l, A8 N8 r* F1 j+ J3 C return
. d8 d1 n% a7 h6 c4 s. k7 c #IfWinActive
& }5 p6 R, M; J3 |2 |2 h ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.8 J! f+ ^- q: d
; Note: expecting to be run when the active window is Explorer.# A7 X& {/ _ S9 g* T8 X n
;
9 ~+ S# p" y! O% Y F8 o1 @ OpenCmdInCurrent()
! y: u' `+ E5 C3 P' f {: `' O! t% y, [# [
; This is required to get the full path of the file from the address bar" e. p( y; |- I3 h# K' c) O+ Y/ }
WinGetText, full_path, A
: K7 C- k' N% r ; Split on newline (`n)
# ?4 ]* e, _1 } F' {/ x StringSplit, word_array, full_path, `n
6 f6 O, e! [0 E: [/ { ~ ; Take the first element from the array
% b, Y/ H$ }4 t" f i full_path = %word_array1%
$ J' ?0 j, r6 H' l- b ; strip to bare address
- S! D# z1 {" O% W6 I- ~: D2 n full_path := RegExReplace(full_path, “地址: “, “”)* R; R- }& t. X4 m
; Just in case – remove all carriage returns (`r)
+ u1 o2 m* i1 G* x6 Z1 Z StringReplace, full_path, full_path, `r, , all! ^& i3 T" q" V& H9 C+ e) R
IfInString full_path, \# \5 w9 r$ z) p0 G$ x" B, g
{
2 u1 [7 q0 A. }! u Run, cmd /K cd /D “%full_path%”" v$ R+ y9 e5 P3 j9 b
}. Q' a+ z3 E6 } f
else
2 U" k1 a# l" C+ v( x$ g( }4 g {
( ^ s# \! w& j! T Run, cmd /K cd /D “C:\ ”
' S* i4 ?. N* }4 }* S }
! l5 t) w% T. {+ [8 K! G }0 M; E! N, X2 D- w3 ]' g) Z
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
B2 p5 I4 n* k" F 这段小代码肯能有两个你需要修改的地方
, n; p6 v( s% ]9 V& O9 h* ] ~3 X4 f 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ k0 _5 z! s2 x9 s# b 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “# h1 O$ n% W# b
|