此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
% h6 o+ n. a8 j5 C {( S 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 i6 n+ C; c! ]7 s8 r1 e$ n
方式一:* Q, Q) W# T' f5 H* l
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,5 x+ ~1 S3 y; V+ a# A
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和( f H! @9 L9 c! B
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 u+ ?) a4 q) `4 X
方式二:
o) d9 B6 W6 c4 v8 `5 _1 D2 y3 X 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:. T' J# J7 o* Z: U, r7 Z
SetTitleMatchMode RegEx7 b& R$ Q; f* M+ A5 K9 e: }
return2 h4 \' X( x7 ]/ ]$ `
; Stuff to do when Windows Explorer is open
& d4 E: A8 z% m3 n p ;
6 u j! }4 g3 c& y9 @! G8 z# E #IfWinActive ahk_class ExploreWClass|CabinetWClass
; i) w# }& ?) R3 B6 Y! H, X4 D2 | ; open ‘cmd’ in the current directory
1 r& n3 a9 ?4 I ;
5 M% x. U' L6 M, ]3 m: } #c::- o8 F& p# v9 Z6 F+ j0 x
OpenCmdInCurrent()
( [" U" w) I6 Y# \ return9 O9 M- Y6 d1 R5 ~6 A' {
#IfWinActive) j; |2 [# C$ o% z, z8 [
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# }1 c+ J9 m8 I+ A! o
; Note: expecting to be run when the active window is Explorer.8 L* k: J3 D8 c3 b) d: M
;! i& W% j" ?, P. E' y" X7 n
OpenCmdInCurrent()9 z9 r- \9 e7 [2 _0 G* A1 {
{
0 r6 v* _" Z7 f ?0 ^ ; This is required to get the full path of the file from the address bar
# O2 Q: z' L/ S. k4 t2 ` WinGetText, full_path, A5 V! J$ K0 n7 h. ?
; Split on newline (`n)3 o0 ?. N+ [4 _1 t
StringSplit, word_array, full_path, `n
' b# G+ ~6 S6 y! o ; Take the first element from the array
. a1 c5 S; U; Y0 }: |/ v* a0 \ full_path = %word_array1%
8 }7 \1 e7 i x: a M; C# R ; strip to bare address
8 B& W. w* ^/ s7 ] ?) J3 W full_path := RegExReplace(full_path, “地址: “, “”)0 E! q& C+ ?& }
; Just in case – remove all carriage returns (`r)# x5 ~* F! x* ~- P1 e
StringReplace, full_path, full_path, `r, , all9 }* F3 I( o" o+ I) n. Z3 G- f
IfInString full_path, \
+ W) S+ J4 o& Q2 t0 H. a+ q- P {- b" g! H2 A f; l6 Q( D
Run, cmd /K cd /D “%full_path%”
X# S( t g2 p9 N- M4 {5 p }
/ e2 W- z9 i R$ \2 _3 S else
6 c) e4 Y' N; t1 e6 P& J7 y {7 h. `: `+ T' _- R5 q' t; j
Run, cmd /K cd /D “C:\ ”& A+ c% |) v w- a3 `" X$ n
}1 [. e# y& e- B8 \
}4 }! V$ {6 l0 b$ `! a5 ~
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。1 R0 G' T0 T8 X5 B5 z# b
这段小代码肯能有两个你需要修改的地方4 G5 [8 p( g. j4 d" `0 I7 }
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
/ X3 E1 t9 Q; d9 i9 L* e 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “7 e7 E5 x5 e' J l* W
|