此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
2 e% G" T; [, @- |- f K 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 [8 {8 ^+ q1 ?, _ 方式一:
5 T, I$ i5 a& d( Y# K+ ~( X 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表," C3 q o, Q8 B4 i! ~1 {! a! e
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和- S# y$ p- k' ?- ?
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。7 _* n$ ~/ W1 u1 w4 X+ i) T
方式二:
% s0 i# }. I! @) |6 d5 n6 h7 L- @ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:; r8 K# j8 i- t' p! w9 I0 r
SetTitleMatchMode RegEx# h8 s: `6 P' ~3 o6 }1 i
return* \5 l: d4 Y* R& \
; Stuff to do when Windows Explorer is open8 H& f# p; V! }3 ~& D% f7 X
;* t, N. o4 M' e. x" a% I1 T) c' p
#IfWinActive ahk_class ExploreWClass|CabinetWClass0 _4 o9 D" \7 F" B
; open ‘cmd’ in the current directory
% X2 P3 T: r, Z3 ^ ;2 e- w# W6 D; c
#c::
) f& h8 t [4 v OpenCmdInCurrent()* z$ u, v8 `* E' K3 h1 k2 X
return3 f5 k) }; r5 A( t' t) T
#IfWinActive0 k. x- ^8 g+ D' i, t; X: i
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
5 Q8 S/ e2 j% {- O) Z; \ ; Note: expecting to be run when the active window is Explorer.
! v3 y8 o0 r, N: I) ] ;
I S, l2 K/ v% F' s OpenCmdInCurrent()
4 w l8 l# U7 A5 c* ` {
9 h+ ?" s( f7 |6 `/ p ; This is required to get the full path of the file from the address bar
% M6 ?2 v: ^! P% v+ X* G% A WinGetText, full_path, A d, x$ f; f. V$ [4 V! n8 Q. A* ?
; Split on newline (`n)6 E c0 l" q/ }6 L- g" a* y
StringSplit, word_array, full_path, `n
5 o3 X( x* L# X# y ; Take the first element from the array, E- D1 ?+ U$ B3 C$ Q
full_path = %word_array1%7 J% v; r& u- g( j
; strip to bare address; G2 m" T; P) e
full_path := RegExReplace(full_path, “地址: “, “”)
5 w7 R1 D( n7 \ ; Just in case – remove all carriage returns (`r); |7 S6 |) {% t* E* I
StringReplace, full_path, full_path, `r, , all
1 i+ p& H& @, g7 q/ ]% B IfInString full_path, \& b4 K0 \, z% g7 |+ D
{+ }! ^" X9 k) [! M6 d
Run, cmd /K cd /D “%full_path%”
- n0 o' m) {* q2 J3 a }
7 R4 Z% m( V5 q% I" R- c) k- Q else2 U5 r& f* D( [" S5 k3 o; t2 n6 z
{5 z" c) Y. S2 ?9 L, v8 v& W
Run, cmd /K cd /D “C:\ ”
! i0 ], Q& k7 X9 e' E7 i X# d }
! B* h P; x. O( X$ e }- E3 W8 H4 A; D- e7 n; K/ v3 o9 Z, y/ W0 |
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。- \1 @1 e1 A1 w, c2 C4 ]% G/ X
这段小代码肯能有两个你需要修改的地方 `1 `( X; a- c5 }' g! Q1 v
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) |# t5 x( `+ S7 \1 k1 \) p
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
& [& r w/ [0 z |