此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
8 q m. n8 H6 y H 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 W8 P+ o$ }, M4 R 方式一:
0 I$ L7 i# w3 v! A, C1 g! @) f 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,5 |' Y. v# n Z2 \* a3 {
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
4 ]3 }3 B+ @. Y3 M+ Z HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 U* z0 Q7 p' h' [9 R2 P& J 方式二:
# k0 T! _8 \+ V0 @: K; a. E# N 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:3 Y( W: `- i* b) E1 V. h
SetTitleMatchMode RegEx
% x1 m4 r3 @0 ^: {# T return
) w! [5 ?9 r, R' D1 Z ; Stuff to do when Windows Explorer is open
, m, Z0 V7 r. }4 u ;- K: o8 a& _+ G. u3 H
#IfWinActive ahk_class ExploreWClass|CabinetWClass6 f0 W5 { ^% }3 G' r6 \
; open ‘cmd’ in the current directory
6 |$ g2 p6 |3 T+ a8 v ;
' s$ d9 ^. Z- b; g# B/ S1 ]3 o #c::
, o& Z( U: M# f3 J$ m OpenCmdInCurrent()0 V- S& g9 `8 {! x# U" L5 ^
return
/ {! S5 s- f" k* W- X1 k4 v% j #IfWinActive
$ }4 l4 p4 Q! X" C ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( \. q1 C9 b s ; Note: expecting to be run when the active window is Explorer.- y4 U N" E/ {2 p9 O! T
;
9 V7 e) `$ _+ P; e! ?$ h OpenCmdInCurrent()
! d/ L6 @! n9 Q7 L, T1 i" N3 j/ @* p {2 y! {* d6 _- @4 m
; This is required to get the full path of the file from the address bar! I" A7 Z7 j' L# s
WinGetText, full_path, A
4 [$ b* |5 z+ }1 [4 F& Y& a ; Split on newline (`n)- l* m9 D0 g& ]$ M4 O1 h4 i8 q; o, v
StringSplit, word_array, full_path, `n
8 { |- I2 o/ f# y ; Take the first element from the array
1 z/ N+ w0 e4 w9 A! G* y9 X full_path = %word_array1%( E8 z( c5 w2 G, o. [
; strip to bare address
1 R# L! C& B) y" r/ e$ E full_path := RegExReplace(full_path, “地址: “, “”)
" j' S$ }! Y1 E2 D# K! \% ~2 Z ; Just in case – remove all carriage returns (`r); U+ K3 v( @6 i8 T
StringReplace, full_path, full_path, `r, , all% b, G* H/ f5 i* K
IfInString full_path, \0 f: t8 k4 v. p
{
& @: Q( i1 y6 p3 k# ]! x$ [ Run, cmd /K cd /D “%full_path%”
: s5 G& h$ Z0 J& s' a4 G+ ~! |9 N) M }! f" u# c8 ?3 P
else
! D4 B$ l; v3 W w9 ^ {- r% \$ [$ X8 ?2 h- U3 i
Run, cmd /K cd /D “C:\ ”
) T3 O6 J5 @! z1 e6 V. E }
3 o# e- H; _ U0 Y6 J+ U/ h }9 l4 ? K# Z- C) ^
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
) M! f$ _( }# u2 W$ }" e 这段小代码肯能有两个你需要修改的地方
3 {+ r; k: P. o! y 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键8 \' a$ R- Z9 p9 V( f, G
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 T3 x8 w5 o1 D g |