此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, G0 y6 A M- G4 V: `2 Q2 o
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
( ~' L5 p0 u5 k( \8 L 方式一:
* I1 E- Z* v" P5 |( o: v 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
0 ?( q4 G2 y6 O6 S3 Q 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
/ W+ l, ?6 { g: \9 |7 k! I HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
2 T: y! c0 F& ~ 方式二:. I% Z7 @: [: z4 u, x3 g
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
5 i- Z! W) i# L# `: ^ SetTitleMatchMode RegEx) C" m6 B4 L/ q# d V! L. n
return: ^, S6 u! A6 V! M8 w4 Y
; Stuff to do when Windows Explorer is open7 n: d1 {0 T( \
;
$ X" I; m% P# a4 D2 V0 E #IfWinActive ahk_class ExploreWClass|CabinetWClass5 P5 d1 |4 l, R
; open ‘cmd’ in the current directory
- `# h& x1 Q! L2 y ;
0 M. X+ x% K2 A, R8 l- B #c::0 J) | I4 a& M( A" m$ n! K4 z
OpenCmdInCurrent()6 q0 Y& v: u# e# W: M
return
6 c. v/ t+ i2 v/ Z6 W. _7 Z #IfWinActive
% H1 N9 D' `9 S/ B, j* J# ^ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
! a; }: u9 B( Z" x/ \ ; Note: expecting to be run when the active window is Explorer." X7 U' R% Y& n& n; B7 l5 ?
;( s6 L5 t" ^& Q# b, E
OpenCmdInCurrent()% m7 y8 l' g: z: l" y# e1 R
{
& r. ^/ a5 e5 J- h _0 q" H5 r ; This is required to get the full path of the file from the address bar
0 C2 k7 f% U. s' {' ? WinGetText, full_path, A
; _" J* p: G# w" Y ; Split on newline (`n)
0 H2 K. ^. f5 D& b6 S% h% E+ I StringSplit, word_array, full_path, `n
, P* ]( @2 I4 L/ x, {" P ; Take the first element from the array' d3 {* n. t+ S3 _ C
full_path = %word_array1%& i8 n( s2 A$ ^+ ~4 W. T8 E* i
; strip to bare address2 M0 q# F \& t0 A1 o8 u" W
full_path := RegExReplace(full_path, “地址: “, “”)
/ y, B9 i# p q0 Q! w ; Just in case – remove all carriage returns (`r)4 o' G. R5 C+ i
StringReplace, full_path, full_path, `r, , all
- \' ? g5 s" D, `4 ? q IfInString full_path, \+ H2 a q3 E* j& k
{
, f% P6 l, W8 B& Q# O Run, cmd /K cd /D “%full_path%”/ n$ K' @6 ?/ o" Y1 H( Z
}
5 }# [6 U( h) d9 x6 G else+ L+ H& k1 }. y: f1 q$ Z
{: f, r4 u7 T( w: H$ F s
Run, cmd /K cd /D “C:\ ”. g' q" E( d2 N5 C N i) Y
}: y% I. `4 d) N! D) L/ v) ]& V& R1 E
}/ N; S; ^* ~2 O" l- M& T0 I8 U" y
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
" c& x0 l- h) p& A 这段小代码肯能有两个你需要修改的地方! r0 h# I, }/ Y1 |* Z
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键% P4 D( Z/ j" z, p" Q. e2 ?
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “) p. C+ T- r1 _3 `: ^0 \
|