此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; I. M7 ~- k& k' Z7 u4 G
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
# T1 m. U; s( R$ d5 E+ b 方式一:
) z, x' G0 j; l# b/ b8 _ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,, x6 e/ B* m2 a+ d
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和1 j: e9 S% W! M8 W
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ Y8 b5 z/ y2 C" N$ U6 V$ u8 Z+ C5 A8 b 方式二:
( R% K4 W5 J" F5 Q! E- U 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: v7 N2 u4 d7 Q: r: f0 X
SetTitleMatchMode RegEx7 S8 @% W0 T. n, @9 C& K
return) ~8 S1 H6 |9 W' u( q6 Y
; Stuff to do when Windows Explorer is open
3 s0 N; J i6 Z6 h6 E9 J ;
: Z+ b V3 a$ d* \) P, c4 Y #IfWinActive ahk_class ExploreWClass|CabinetWClass
2 V5 ]9 t* [& ]: Z# P ; open ‘cmd’ in the current directory
, G- ?& @. b+ V: W- E$ n ;
2 X: p4 _* t# q4 Q) ~8 ?8 e #c::7 P) A: F4 i3 }3 E+ w; ~" k0 F
OpenCmdInCurrent()2 k* l* Y2 p, z5 ?
return/ _& n8 C' J; D3 n" j$ }8 I4 c5 u
#IfWinActive" A5 C. [: J, E( u6 B- [
; Opens the command shell ‘cmd’ in the directory browsed in Explorer. U1 M* |& U$ @ G
; Note: expecting to be run when the active window is Explorer./ U9 W4 U& A, t/ h9 ?6 [1 p
;9 S: b. p9 r8 C1 Y' x/ G
OpenCmdInCurrent()2 s, W. V0 z @/ B5 s# m( d
{- }. q5 ~1 S4 @5 p
; This is required to get the full path of the file from the address bar9 P( @3 \$ t$ z6 b& F9 ~2 F% q
WinGetText, full_path, A
" z4 C5 g( R% e9 { ; Split on newline (`n)
8 d4 }8 |! c$ ~ StringSplit, word_array, full_path, `n& [$ C# U1 o H' h5 P. H6 t- o
; Take the first element from the array0 d/ o4 |# a5 z* M* s# |" v7 [
full_path = %word_array1%: H( ^$ \8 s" U, v4 Q& S2 }4 D* m
; strip to bare address
6 O9 O. ?! j' `5 n full_path := RegExReplace(full_path, “地址: “, “”)
/ |# u) N4 ^$ ~( D8 e6 D ; Just in case – remove all carriage returns (`r)
5 @) l# W: \* p! U6 x" |" d StringReplace, full_path, full_path, `r, , all) r% t; a) k/ j! ]: @+ G+ \$ C. m
IfInString full_path, \7 ~- q4 {1 c& U$ Y H# o; J% }
{
0 R' E. m# W3 h4 F Run, cmd /K cd /D “%full_path%”
- E4 y' A2 D& }* O6 m& P }& B9 g3 b& h$ @) V* O: Z' G
else0 i4 w* e1 Q4 k
{% k' V/ P8 m! R+ M+ z% X( D% V
Run, cmd /K cd /D “C:\ ”/ U p+ M* w- q( ~8 k
}
! K0 Z* l: V! @$ _ }; ], V9 ?* ^2 m1 S6 B' U; z
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。- q: A( _3 I+ D9 u4 K
这段小代码肯能有两个你需要修改的地方3 Y1 ^; T' R8 ~2 Z2 R$ r
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
! f6 I. O2 n2 e( |' } 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “" T; W- o: o+ J6 G7 P
|