此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
' N2 }' v+ P l 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
/ K- A: u: s9 |' T5 \, S 方式一:& _0 J( r9 I4 s
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( O; i" H: u; m- V! H$ I! p
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 o( W" v! k; M3 l- Z$ Z2 c: [. [$ _0 |
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
4 b6 _! O# h, U* C$ ~ 方式二:4 w6 Q3 t' z6 k! G' s
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:6 l3 [4 ^9 T0 a. g' P, K4 Q5 C& J* I
SetTitleMatchMode RegEx# t" z/ G/ X8 d) G( k- y. u8 A
return/ ^/ u3 n( G9 {
; Stuff to do when Windows Explorer is open
$ p/ a/ }6 q/ A9 ?% @/ l& \" J3 \ ; J% O+ J- ~/ f. y" v2 X5 ]8 M9 s/ v2 `
#IfWinActive ahk_class ExploreWClass|CabinetWClass* c% Z# |4 v+ m4 v/ G, Q
; open ‘cmd’ in the current directory
4 ?4 r& ]8 P+ `4 e) B' M/ S$ D ;
3 H- J5 p6 ]& g3 w1 Q" p0 d. X' a #c::0 t( ~8 p! O, X# ]8 V, ]# q! M& L
OpenCmdInCurrent()- }) ^- {* j/ P
return
3 v9 p1 U/ X9 D" { #IfWinActive& P6 A; U! n; j( X( y0 w
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
3 n- c$ v- W% D* h& e. O5 q ; Note: expecting to be run when the active window is Explorer.: m. J$ i$ x9 u D! M
;. I4 }/ X7 j# s' J C. p4 S0 p
OpenCmdInCurrent()
& h. @1 n8 X/ h {
" j5 u: @4 W& X/ f" f( m0 D8 k ; This is required to get the full path of the file from the address bar1 ]9 I9 ]( f ~/ g0 S
WinGetText, full_path, A+ C& Q; j: t( d9 z
; Split on newline (`n)3 o ?: j; ?7 b _8 M- I1 B& p5 Q
StringSplit, word_array, full_path, `n
+ W9 h1 M! w" Q( n ; Take the first element from the array
/ {6 ]. F1 V$ O9 G0 q/ U& o- g- B full_path = %word_array1%
* a: ?8 [# ]' \3 F8 C2 h& R ; strip to bare address
+ C% B7 Z7 R$ W( x full_path := RegExReplace(full_path, “地址: “, “”)1 k8 \" {* T$ B k
; Just in case – remove all carriage returns (`r)
( l8 l0 i5 `- Y StringReplace, full_path, full_path, `r, , all' F0 i' L& @: s. ~/ Y# z0 X
IfInString full_path, \* f+ n8 d0 H; X7 Z! b* X
{$ r. {, Y0 `4 f
Run, cmd /K cd /D “%full_path%”
2 I* A3 H/ ?" d$ z }
' E# E2 Y# {' m0 Y2 U& K* a else6 j/ \9 H& |8 R" w% B! p
{6 B5 c( c4 v! a2 F- @4 G
Run, cmd /K cd /D “C:\ ”/ ~. n% t7 h7 W& y' l
}# C9 c8 o! Q3 A& u- D; o1 q* O
}0 \2 r. k, ]% S; R
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
' s! E: {' t/ ^* Q 这段小代码肯能有两个你需要修改的地方4 ?7 v7 ^9 G0 D# _9 }4 _( M
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键8 T+ l0 W7 V5 m. y# H _( X
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “: U8 \' j* o. `. e
|