此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) r- k8 i# w6 T# c/ g X C
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 }7 A; _, V z$ Q. B 方式一:
4 v. d2 h9 W& X+ N1 i/ ~8 A" x 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 D0 V+ H% k% w0 X9 t
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 A/ Z1 U" e# e
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" W2 ?0 q- A5 D- ^8 N9 Y9 p 方式二:
( N- ]9 c7 o6 P2 V/ n 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
: _4 v5 d3 M" z9 M) Y SetTitleMatchMode RegEx1 B" x" a3 E; q' i
return& I- f* N, Y4 _! U( C
; Stuff to do when Windows Explorer is open
3 d m. D1 T5 L ;
2 i, i; |$ E: |' q/ ?( N+ E #IfWinActive ahk_class ExploreWClass|CabinetWClass
. M# e; L8 Z3 k) e ; open ‘cmd’ in the current directory8 ?1 \# _& J5 c- ~% C# h& a
;
) h) o5 o V' f: E1 L2 x0 C #c::" X, _6 V3 l" ~) `0 l+ p# g
OpenCmdInCurrent()( r$ X: u8 D+ m1 s+ l& I+ f
return
0 ~9 {& a% w+ _: E- E #IfWinActive" E# p) J, _8 Z% G
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
* c# a5 j3 D( `& `, s2 U" c/ w' z1 {+ b ; Note: expecting to be run when the active window is Explorer.
1 C5 ?0 q& M. Y ;
3 u# _) u. l3 d2 E OpenCmdInCurrent()! a: R& Q4 U1 H* Y
{
4 e' d* o: x+ }0 F* A$ Q2 i( u0 M ; This is required to get the full path of the file from the address bar( y. l" C* }6 ~" P
WinGetText, full_path, A7 ?: U; @' T# s3 V ^, ~! h
; Split on newline (`n)
+ c/ c9 p }5 f8 C0 n- @ StringSplit, word_array, full_path, `n
" p; @' z5 g+ ^( x3 t+ T/ ^ ; Take the first element from the array' u0 |/ B k6 S g8 A/ W: _1 G
full_path = %word_array1%
% m% F6 l8 X! |7 e; j5 s5 Q* [ ; strip to bare address* y/ T8 m. ^% Q6 `0 U! a! d" Q
full_path := RegExReplace(full_path, “地址: “, “”)
/ ~% A# X* a! A; n3 x ; Just in case – remove all carriage returns (`r)* X6 ]) V7 t% L: `; N
StringReplace, full_path, full_path, `r, , all/ x+ A+ W4 i* q$ Y9 O
IfInString full_path, \
: x& @/ p/ A8 C6 B$ { {5 l3 t; L: n' V" b0 u e
Run, cmd /K cd /D “%full_path%”/ _% S y5 f9 ^+ X! J* |
}$ G6 T2 Z) L* M4 X% z w" X6 L& C
else) E5 J1 g( g- h( R8 i
{2 i3 S4 S/ w0 G( T) y$ }
Run, cmd /K cd /D “C:\ ”0 z( z$ n; N4 v( u/ }3 f* ~/ B
}
$ r: n. y5 `( M! g' Y }' ~6 b' d* t3 `
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。, `1 D% o; V" N
这段小代码肯能有两个你需要修改的地方
& b$ t5 n, U3 i; w 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
4 G+ D4 r4 _, h" o3 r 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “3 ?+ o: y$ ~' L3 H0 n2 S
|