此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
( i8 M! n# Z7 r5 i. b 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。2 Z1 G8 \6 \% g9 c6 b, ^. \
方式一:- S: C. G* Z; Z6 \. p0 ^1 `, V2 E
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
6 ]& G: v7 u( f2 S& M$ j4 I1 i 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
* N4 [, J; }% {& g3 U9 @ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
1 l+ {# X* `' o# T0 Z 方式二:
' V1 m2 C' M9 P# ?, C, S |- w& G1 I 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 s6 _' ?; G: {+ j6 s b- s
SetTitleMatchMode RegEx$ Z" O1 D7 y5 N% B$ Z
return/ h& g2 x4 X3 g* a/ `/ A+ Z
; Stuff to do when Windows Explorer is open
5 I* O; q- \- x% L% B. u8 {' D# X ;
+ }6 r" k1 ?( J$ q5 C v #IfWinActive ahk_class ExploreWClass|CabinetWClass
- y+ k! _, K8 g7 c( \5 x ; open ‘cmd’ in the current directory1 M; l8 g. E- d0 N! o) T
;
1 h2 r# T5 ?9 \( U4 s" y" p #c::
' |6 A. }# ?. [" z4 S OpenCmdInCurrent()+ t3 K( v; u9 b2 T% V' c0 U
return7 X0 h9 M) G7 t y' c8 C! r
#IfWinActive
* V5 V- U# |; T ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) N9 s( S9 D) V1 v
; Note: expecting to be run when the active window is Explorer.# N) T+ P1 n1 @
;
+ c) [9 f! w T/ [; s) E OpenCmdInCurrent()
$ e1 c) F9 n/ p# _! S9 O! @ {
3 b# a6 ]) }, P2 @; H ; This is required to get the full path of the file from the address bar
# H8 H0 p' p# Q- c! [ WinGetText, full_path, A
4 w% Q: b# c) t% F5 x% n; E ; Split on newline (`n)
/ F4 @' J9 b ?8 i! `& @6 o) o StringSplit, word_array, full_path, `n
$ s/ o: S& P* O1 u: e. ? ; Take the first element from the array& R V/ o$ o' {! N% ^7 j
full_path = %word_array1%
d/ e0 w% w. V) c) F/ s ; strip to bare address
3 I/ y7 H9 p7 ~- K full_path := RegExReplace(full_path, “地址: “, “”)# r: I3 J9 |1 a, h+ p
; Just in case – remove all carriage returns (`r)) n: s2 D3 k* ~3 f, _& T& O
StringReplace, full_path, full_path, `r, , all& X; Z+ I! f9 Z& A
IfInString full_path, \$ |: F1 S# y& B7 R5 d& B+ v
{4 U5 p1 x9 r$ q8 F/ `8 z
Run, cmd /K cd /D “%full_path%”
$ S$ K+ I0 C6 K H* Y }
# Q1 e3 H, m" d else
5 q2 ]0 O( K# M# p; k {
# ?- L1 N7 m4 X7 x0 q. M; a Run, cmd /K cd /D “C:\ ”
+ }7 ]. U$ m. F% z/ J2 E3 Y. J }
+ q1 g) _. ]3 ~7 H- A' d4 M, a }5 ]- I# Z1 M1 t e; \9 `
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。/ X8 V+ P% n; p8 V+ |
这段小代码肯能有两个你需要修改的地方
1 v7 B, S) ^# U1 \, ~* Y- w 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键8 A% f% f$ n5 s' N" `
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
% o) Z+ h X( h% J3 d& i6 L |