此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 r4 K, J W7 K( }, p8 o
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
' j/ }; X; w4 J+ k* ]' [! W 方式一:
& p* W/ x q: ^ @& S0 `* b' u8 ] 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
: j8 J% E- h/ N) B& C+ E( _ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
. s$ W! \0 `0 X- A& O: p! h HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。: Z7 e, P( f. T. g/ N, c
方式二:
. V5 j: H4 X# v# A" F U 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
+ g; |$ ^$ C" R$ [8 \: e# `0 L SetTitleMatchMode RegEx2 s# s% S, s) g7 G; D6 i
return
; R9 N4 w P/ _8 Q) z) R# G ; Stuff to do when Windows Explorer is open6 X1 K0 w0 a5 b
;4 z" u8 i- p; O) [4 D+ n
#IfWinActive ahk_class ExploreWClass|CabinetWClass
1 F6 w: Y8 z6 s- P# j; z7 l; @1 W ; open ‘cmd’ in the current directory
5 C, E: n' A) D& A3 M" q ;
1 _2 |" |+ w' {+ I' @ #c::0 g& r( b1 I, z: T
OpenCmdInCurrent()
& _8 h9 c- l# G# d) M return4 u! ~: E5 L4 `5 X3 u+ n
#IfWinActive
5 ^4 A) h' [. T ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
6 h5 z7 z& @- T/ a; a ; Note: expecting to be run when the active window is Explorer.
- D9 U+ H% q$ E. _- U w$ T5 R! x0 b/ V ;
% l: M7 \3 e: O7 f, B OpenCmdInCurrent()
( J. g8 ~" b/ e- W6 e: G) r {
" O4 B& L6 s- p3 J* R ; This is required to get the full path of the file from the address bar7 z/ A8 |- w5 i( d: i' t0 X
WinGetText, full_path, A
' p" X/ N' \/ D+ H( d# j- ?' [ ; Split on newline (`n)% l& L! F( @. H( Y+ t
StringSplit, word_array, full_path, `n9 S1 u6 ^& N6 d1 G2 h7 M
; Take the first element from the array
+ [# p8 K5 D7 b; I) F F% X, |2 o full_path = %word_array1%8 [& d* P* y7 _- }
; strip to bare address0 n# c1 s9 k4 w% i
full_path := RegExReplace(full_path, “地址: “, “”)6 ?0 S# p& i5 x' R# \( p0 r& K( t+ f
; Just in case – remove all carriage returns (`r), g4 g& D4 d( V6 _: G* w
StringReplace, full_path, full_path, `r, , all0 ?! v( ?* h0 S0 ]" f
IfInString full_path, \
9 _2 @ Z6 W; L# G {
* Z* g) ]! A; A# {; Z- n Run, cmd /K cd /D “%full_path%”
' C% B) o& H! u7 i }
6 d' q9 U% g: f3 N/ A; c2 S4 k else. t0 @& } W6 j# `
{( x1 H H6 Z' C; b6 A: Y7 a
Run, cmd /K cd /D “C:\ ”) f5 R* [! p. b+ J6 a
}4 H$ S. C. z6 c0 C0 f: W; T
}* @2 r( s( r& U" n6 u( O; D) x
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
) `1 J8 b$ {) z5 E a$ A+ } 这段小代码肯能有两个你需要修改的地方8 n. Z! D4 O2 g9 f
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键6 w9 o6 i1 P0 b& o% N& ^
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “# c$ o, o8 d; k+ i# ?& |- S% E
|