此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
& t3 x, G) v m( u8 A6 J 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% ]2 e; R2 e# J5 Z, Z
方式一:
9 |6 C: j S5 W. m 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- `2 Z5 O0 s, f1 M* a
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 N, L( D7 e5 W. e
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。% P& B/ F) w" s. C# k
方式二:
9 H( r* N# l. q7 u% O7 A7 \ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:0 E/ V7 R3 Z) T
SetTitleMatchMode RegEx, o: L' [% \& D+ i3 n
return
0 d) U5 ~" u3 o" ? ; Stuff to do when Windows Explorer is open
8 e4 T7 @9 |' l4 J+ I. D+ H5 V- } ;
- s% x/ s1 ]. V* p/ B9 `* _# J% u #IfWinActive ahk_class ExploreWClass|CabinetWClass
9 N9 k9 U J" E! l( t; F8 k ; open ‘cmd’ in the current directory+ ^8 |8 r* D0 l3 D
;
' d- b, C" p# _/ \7 L _: A8 n- w #c::
1 L$ H1 h) H( p8 ~; E OpenCmdInCurrent()* y: a/ m7 x) F& z( B( }- ~
return
* k3 Z8 S+ L+ r* C a' `5 N7 V- i #IfWinActive r8 N8 H4 e7 J2 z
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.$ T, J( [! Q9 r* f I* h, k: v
; Note: expecting to be run when the active window is Explorer.
% r8 z3 x, K* ~, i! U6 G* `. ?1 ~ ;
, a/ Q7 y& c# B7 x" ~& x7 I5 w OpenCmdInCurrent()' m1 s; I1 N( c8 m8 Z
{
, H" L4 K. ` `" b- ^; T: D+ F- L ; This is required to get the full path of the file from the address bar
( `9 i+ d o" a E: E WinGetText, full_path, A
O' W9 y. ~# N% u s& ~ ; Split on newline (`n)
- S1 B- t( }& ^4 z- R StringSplit, word_array, full_path, `n
2 ]& @6 W! g/ N x0 \( [ ; Take the first element from the array
5 {5 @$ f1 ?+ j full_path = %word_array1%
" ?, o8 \- V" N& z ; strip to bare address
# {) H1 e8 M1 |" ^; M @ full_path := RegExReplace(full_path, “地址: “, “”)
- h) l" x" x) S# i1 U ; Just in case – remove all carriage returns (`r)
/ G$ ?% B# Y6 o7 S; i StringReplace, full_path, full_path, `r, , all. B+ g/ M7 a; ?% w; M
IfInString full_path, \
( r6 {8 [$ ]5 H# d2 n4 n {
. |1 H/ \# j+ ] X9 x% D Run, cmd /K cd /D “%full_path%”
; g5 H; y: c. ^0 N+ S% q8 o }- ?9 j# `2 `+ m
else0 L' z I" N |. p! W4 y! m- Q
{3 v+ Z; H6 w. Q) p) d
Run, cmd /K cd /D “C:\ ”; D0 U" ~- `2 V. }1 ~3 k
}4 d/ a, @( ]$ m* k# y6 [: j% S% k- _
}: l; r% N+ Z% D) m4 L, R# P, G) {
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" M+ K# T1 @5 W1 _
这段小代码肯能有两个你需要修改的地方* w+ o& e; r$ z% U w, o: _
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键( Q/ D2 C. |+ x; ]* w* _
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
( F+ `2 i9 R3 s# v8 @3 b- U3 d |