此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
/ `1 G o# A& a$ f% [; a 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。; W$ I0 B1 i+ s7 |# f' t+ d
方式一:' S1 d+ L4 ~1 z5 C" p8 l
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
; q6 c9 h0 P9 h2 M2 z 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和1 R+ `9 e7 O9 t, J% O" S
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
, Q2 E2 B- Q( {6 J* ~" s G0 [3 `. O 方式二:
?. K$ n! t! K2 j4 H! C/ U4 P 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
E- {" c* h2 m( x V! l. |& C( J* _ SetTitleMatchMode RegEx `. s0 n$ j3 s: [' y0 r; c
return) p: L2 h+ y+ b. d
; Stuff to do when Windows Explorer is open! @+ k1 z8 ]. N& |
;
1 z, }! g( J( H #IfWinActive ahk_class ExploreWClass|CabinetWClass
7 Q, I5 V# o" O% i+ \; `7 s ; open ‘cmd’ in the current directory: G6 ^, x. P* N4 N; k% ?# H/ |
;
* C) Q, d H5 f( g9 U #c::
9 F* ]4 q# x$ q! g% w5 Q/ E I3 s OpenCmdInCurrent()
1 M+ ~8 A+ a, h. y: e0 n) d return6 _" s( ^5 S# G( Z
#IfWinActive+ ?, Y- w. p1 b, a; {& N
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
; M0 e! Z" U' X2 Y ; Note: expecting to be run when the active window is Explorer.
2 s" m' N5 E/ s ;* R; N5 c4 e1 _# f8 z$ D) U
OpenCmdInCurrent()2 z& F) L' |. C8 a1 t
{
3 d& j, Z) \7 x1 a d. l ; This is required to get the full path of the file from the address bar# h2 q$ P2 Q3 j) e
WinGetText, full_path, A
2 E7 o3 |& l- `& N& G h# p, ] ; Split on newline (`n)! [- o, {: c7 _) V
StringSplit, word_array, full_path, `n
- S$ n! s& e7 P. L+ C6 K* l2 J ; Take the first element from the array7 b e4 A3 C' \) Y9 ~2 t: p
full_path = %word_array1%7 X: T' H' E6 V$ z( z! P% H
; strip to bare address; U) s- L8 h. M) R4 I+ A* D
full_path := RegExReplace(full_path, “地址: “, “”)
+ z2 Y2 f: [3 M/ h; h' ^ ; Just in case – remove all carriage returns (`r)/ f/ V- B7 Y" C7 F5 x! e7 b
StringReplace, full_path, full_path, `r, , all
' n- D6 p8 p3 X$ w IfInString full_path, \
/ l7 s2 Z* x8 m8 r" x {
% a3 o: z" o1 \% b$ Q0 L; a' o$ {2 I Run, cmd /K cd /D “%full_path%”
4 l- E8 x9 O6 F$ e3 { }4 z) g; w4 l* r! D
else1 T, K- e8 Q* N
{* `2 `( N; |: W5 b* m
Run, cmd /K cd /D “C:\ ”
( z5 J' b' h b }
1 G2 D; h2 E. {. H; R. { }7 v- j7 D7 h: g2 b
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。( @4 y8 o7 Y0 V0 u! {' g) S
这段小代码肯能有两个你需要修改的地方! D; ]$ \7 Z- v |; p
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 ^+ g% c5 Z Z% F# R% [ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “8 d# Q; J4 q1 `" b4 v) h# r
|