此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; k6 Y3 ]. V) q/ n5 }+ o' `# }
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
# |# U5 r3 C* k* d/ }" z8 S 方式一:
) ]* D" s, T6 A% n( _4 B& s 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
. [8 H, O, {% ^& r2 O9 ~ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' C* [+ y, l. E: S6 g) j& p
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
: G% A. J8 f! P# ^7 \ 方式二:$ b7 A/ x5 R: o6 e# S
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
3 n/ f! f6 I3 u SetTitleMatchMode RegEx
4 _/ w; F0 W& g' Q9 X+ C return: V; C$ V2 z% n7 e2 ?+ N$ V
; Stuff to do when Windows Explorer is open
4 g4 P3 j9 u( v ;: w& Q) v7 D1 K; y. w& k" _8 p
#IfWinActive ahk_class ExploreWClass|CabinetWClass
+ B$ |" o5 m* |' ? ; open ‘cmd’ in the current directory
9 _: f( d: d+ K. l$ r6 R$ Z0 H8 x+ z ;# W' k+ i7 d- R1 f8 [4 o
#c::
8 t& _2 S6 ]4 b( a2 A3 c/ R' f/ o$ c4 W4 L" _ OpenCmdInCurrent()
6 I# O: w! S5 K: x3 o6 g% y& b return8 ]. v; E& `) l1 r
#IfWinActive
( Z8 o2 k# A4 R2 }$ d. P ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 d4 K! W1 t- \( k
; Note: expecting to be run when the active window is Explorer.) s+ q, Y! P: t" [
;0 M9 ]) @% g; o' _9 ^
OpenCmdInCurrent(). V* n! B# W& V" l% e* R
{ q, d) S; y9 {2 f
; This is required to get the full path of the file from the address bar
6 U6 f+ P* W' x' x! U* L5 L WinGetText, full_path, A
7 n; K* d8 Q0 L ; Split on newline (`n)
5 n+ m# k0 D; v( q5 P, F' O/ t StringSplit, word_array, full_path, `n! l3 r S% U" }! }
; Take the first element from the array
2 {, z8 ^6 Q/ b* u1 t- q4 O full_path = %word_array1%
8 `" @0 M- v0 e2 z y7 }( e; [ ; strip to bare address
; w+ M1 l! m' f3 G full_path := RegExReplace(full_path, “地址: “, “”)
: ]3 g) ?3 T2 Y; j ; Just in case – remove all carriage returns (`r)
& U' O3 ?- g0 M @, s \4 t StringReplace, full_path, full_path, `r, , all
. ^" \+ q; P' I! B+ j# [ IfInString full_path, \& _ {, }) A4 [$ Q) c% v3 C5 M
{. @1 q4 O! e6 M" j
Run, cmd /K cd /D “%full_path%”; n5 v w, _1 o7 T+ R0 A: k8 ^
}
# Q9 ~! \. O1 m0 ?8 w else- e. [9 } e* P& V) z4 p% ? ]
{
& r3 c8 E& n) V/ e0 U6 p6 M& N" |9 B Run, cmd /K cd /D “C:\ ”' \ D/ F- {' Z) g2 R; I
}& a2 E6 }0 U% T8 V. x9 ]# c) q
}" h% @0 M" `' q3 q- N9 M4 J
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
' k& D! V3 H9 q6 t' ?! { 这段小代码肯能有两个你需要修改的地方
" a0 ], I3 S9 M6 m0 A 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键6 Q( g* E7 `8 V- ~6 K# `2 r; |
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 y s; |( Y! c! E/ E P |