此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
2 e! o+ M8 n; y/ |6 u' [ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。1 W6 x; Y* T0 E/ ~& I4 _
方式一:
* ` q1 T7 s6 w8 m4 h# v 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,4 x1 P3 q, g1 K
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和$ Q. G* V1 a- J! G1 t& w
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- Z/ N7 c2 C! C! S* f
方式二:
! i8 Q" @+ k9 T2 T8 w' T3 v 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:6 k' i- {; f1 o4 Z- e
SetTitleMatchMode RegEx
! x0 `4 u5 q# t* B7 s5 K$ `3 S! F return
7 i( q/ f5 m+ K3 F- p9 ~ ; Stuff to do when Windows Explorer is open
/ b+ T; c* z$ J; z& K8 g; g ;
6 G6 r% k' b) e" n #IfWinActive ahk_class ExploreWClass|CabinetWClass: d3 X. t% F/ F& ^
; open ‘cmd’ in the current directory0 i p: `( s( q' |
;' g3 M4 r$ U: n' I
#c::
/ J/ F& y6 L* `. p, b OpenCmdInCurrent()5 C7 _: b) l% {
return
! \- y+ n* K; |: b5 m0 Z/ m( _ #IfWinActive
; k. k( Q2 z) q& k4 k ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
* ~$ t P3 W8 Q. ^; Q8 K ; Note: expecting to be run when the active window is Explorer.
" \0 m, V5 ?5 R1 l! e ;1 S+ L; G& Z+ `' _( ?, E7 O! v% d
OpenCmdInCurrent()
; y% M3 X# f1 l; u, ]7 D; c {
3 Q- P7 R [- [0 s! q! ^5 o ; This is required to get the full path of the file from the address bar
6 \+ {+ T, i8 c9 t8 W9 d4 m WinGetText, full_path, A( d# e; a1 k/ H7 [* p3 f
; Split on newline (`n)
0 `0 g7 D8 L( I4 o; p1 @ StringSplit, word_array, full_path, `n k) O. o/ t" y& A/ P$ M
; Take the first element from the array
7 `$ u% g. U' S G% P) V full_path = %word_array1%
' B. h B, \% ` ; strip to bare address
0 H( ?4 u) O, B$ d5 u9 a full_path := RegExReplace(full_path, “地址: “, “”)1 S' b' L' |% Z% E0 p) }
; Just in case – remove all carriage returns (`r)
2 S; h) f+ C; F7 j: e StringReplace, full_path, full_path, `r, , all7 }9 \$ `7 N6 J! a" m) B
IfInString full_path, \
1 H6 O: x0 ~2 Q; p0 Y1 w. T {8 z6 r) x4 X A2 U) g$ i4 ^
Run, cmd /K cd /D “%full_path%”
1 z8 X* S P! F }( u9 p5 Z% D0 @8 c2 |; \
else @5 f6 f0 ` K9 W2 h7 B* g+ z
{
6 |) L$ a4 O1 k Run, cmd /K cd /D “C:\ ”
4 o4 `! R+ J, X/ V$ G" A }+ M0 @4 H1 |( | K& g: p
}/ l$ [8 r& w/ k$ V
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
0 I" {3 V6 P7 B/ s8 D 这段小代码肯能有两个你需要修改的地方2 t |; E8 y) F' s$ X
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
% ~: V2 _. r; \* {7 q4 c% L) V 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “7 t( d% {- b/ g7 ~" _
|