此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) p0 {! ?: z* @& d+ h% }
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
+ `# Z8 x. B3 Y1 j& ] 方式一:
. g; S# K5 {; }3 C( o+ Y 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
# Z- V0 P1 j; O 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
6 j" C$ L: s* Z0 n3 y HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。5 s& f( x4 ?8 p
方式二:9 C, X7 |+ x7 q7 o D- q& t4 _* j
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:3 u, K8 a, S9 X- i2 [3 e- x
SetTitleMatchMode RegEx1 e& a& p, c+ _$ i1 C
return8 R* x8 C5 q t" T# H! Z* g' E% R
; Stuff to do when Windows Explorer is open" W. c- }0 j3 O V( j# T
;
" i5 _6 w8 `7 J; W1 Q* h* Q& j #IfWinActive ahk_class ExploreWClass|CabinetWClass: V5 J% F$ J+ g( U; _# E- K
; open ‘cmd’ in the current directory
* H5 w3 ^ s% z4 a ;! y; E' m% ~; |- `, J
#c::) b3 J" F5 F6 c" H- Z6 Z
OpenCmdInCurrent()" g) `8 d, j& G3 R5 z$ z
return) S& L' Z7 k3 S/ D; i
#IfWinActive
/ o, ?0 J: [* v6 X) [ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.; O* g1 e( j/ G8 X; p" J7 k
; Note: expecting to be run when the active window is Explorer.
6 G# ?) h0 I- g# @ ;* m9 P) D6 {$ K$ w; P& A
OpenCmdInCurrent()6 w" Y9 T5 c5 H, m& L& }9 W- T" ?
{/ P, ]! d' Z/ X Q
; This is required to get the full path of the file from the address bar& S- O9 ]/ M1 ` b
WinGetText, full_path, A- k0 L% z* N; a( N" l" [. `) U
; Split on newline (`n)
/ I8 E' ~+ P. S/ a StringSplit, word_array, full_path, `n: ]* V8 _9 F" \: I
; Take the first element from the array
8 E5 t( c, q, e ]# O0 o full_path = %word_array1%
& w: p1 H4 ]3 n! _# b# m7 K ; strip to bare address# m7 \2 k) R7 X4 o" N* r
full_path := RegExReplace(full_path, “地址: “, “”)
" N+ ]0 H1 {0 A7 e+ u- o ; Just in case – remove all carriage returns (`r)6 U7 }: }0 _/ l/ O4 \- B
StringReplace, full_path, full_path, `r, , all
* ]" ^. D! m2 N+ | IfInString full_path, \
& t, W! _8 G }- ~3 K. ] {
5 W: t! P/ ]& ^' L7 @' j Run, cmd /K cd /D “%full_path%”0 Z; Y! q. I. W, h1 n+ p4 g
}
9 }2 Q0 W1 B9 M+ B else
' C. M0 ]6 u; d' e4 C {2 @# x( `! Z1 p) m
Run, cmd /K cd /D “C:\ ”: ~: l2 N" \9 ~7 N: B' Z4 D0 v
}: Z. o/ f+ d6 M& C
}# M5 Q, I% B* E* n' J5 s# u
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。) V: J9 Z# ` U& a
这段小代码肯能有两个你需要修改的地方
$ [# x: `" _8 `5 H0 X* U) n( C) O 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键4 J. w1 z1 w' G& y
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ I0 E9 d- Y0 G( X9 Z. c; e4 e
|