此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
" S4 t4 U' l+ r( h6 _4 K8 H% R 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。. x0 m; W1 _8 M- s
方式一:
3 d" e1 A+ L0 H, M* b 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,: i/ k# j1 s9 G8 }8 v' ?: e; x
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
" U: u( R- \. f( k HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。2 d2 A: d9 `; q# Q1 l2 ~1 w$ |
方式二:4 E7 A: O/ C1 v: B( D' G- r
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 g# e1 X" O$ { SetTitleMatchMode RegEx
2 w/ i {% V8 n0 \$ N2 Z$ m O return
. v' D; W& E5 h6 V6 A8 c ; Stuff to do when Windows Explorer is open8 `0 U3 r, b3 f# K9 ?! S* |# }% Z
;
. Q* y# Q) \: a! F9 V, U) w3 w8 D. Z! I #IfWinActive ahk_class ExploreWClass|CabinetWClass
9 Q7 A: ` a; G! Z! x7 ]( y ; open ‘cmd’ in the current directory
1 g* k; B! q' v' B7 N+ ~ ;% D6 S. T7 ]) M" O" G; X, ]
#c::
{8 v |2 k- h% i- F OpenCmdInCurrent()
; d9 b' Z2 F) K* O @6 _8 E0 c return
5 q' {8 N, D, ~7 @5 [6 H #IfWinActive
6 ?( U6 ?5 O) y7 c ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
4 m* c- I# ^; S* s ; Note: expecting to be run when the active window is Explorer.8 e+ Z, Q G) F& F1 u0 R* n& ^
;- C- n" L6 }1 |, q; W
OpenCmdInCurrent()
) F/ d8 o5 |) y2 d1 |2 Y {
$ t, o9 A2 v$ v3 B9 Y ; This is required to get the full path of the file from the address bar' L' I! ?7 O4 `' O% a7 |
WinGetText, full_path, A
$ Q# O8 [4 P% P! j ; Split on newline (`n) B2 S, x: g2 R4 v4 }7 J4 L
StringSplit, word_array, full_path, `n
( \' y, D% M Q l) b; Q: j ; Take the first element from the array- E! Z) S' O; E5 ]: ^
full_path = %word_array1%2 V; n8 w) {2 z5 e3 n* `
; strip to bare address$ d% s* V( ?* _ K2 L3 N# P4 f
full_path := RegExReplace(full_path, “地址: “, “”)
+ T. r% h1 ]! D8 Q ; Just in case – remove all carriage returns (`r)) b+ I/ Y/ `. m" I, g& d8 E
StringReplace, full_path, full_path, `r, , all
0 Q3 o. W/ N1 o0 v0 c) ]3 ~ IfInString full_path, \
' e' z2 H- |5 n' a+ A {! s; F: U1 c- g1 D% _
Run, cmd /K cd /D “%full_path%”! Y; C$ O! ^( F i
}; k! w9 }4 _+ x5 T6 l# ^; P
else3 y, t5 I- A/ }! t' Z7 Z8 E
{ K7 P! H) ~# ]& E X; V
Run, cmd /K cd /D “C:\ ”
* V1 s8 Y. X- x o9 T5 h }7 a% F2 t- H; t% c9 w3 l
}2 Y4 v5 T. S! S2 m2 r+ `# x
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。- |6 m* ~/ l5 ~% ?
这段小代码肯能有两个你需要修改的地方
- E6 D: J M! a 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
& }* Z W2 z1 ^4 T. L) F 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
& _/ z: J! b; }: o$ h4 a0 c |