windows的自带游戏空当接龙,其中第617局是比较难解的,需要尝试的次数比较多,而且经常忘记解法和步骤。
原本希望使用autoit或autohotkey、aauto一类的工具,写一段自动化脚本快速解决这一局,但这些工具需要安装,而且容易被当做病毒。通过office中的vba调用windows的api,对游戏窗口发送按键消息,可以快速演示解法。
declare function findwindow lib "user32" alias _
"findwindowa" (byval lpclassname as string, byval lpwindowname as string) as long
declare function sendmessage lib "user32" alias _
"sendmessagea" (byval hwnd as long, byval wmsg as long, byval wparam as long, byval lparam as long) as long
const wm_char = &h102
sub f()
s = "83 80 83 81 80 " & _
"20 27 72 " & _
"48 46 41 48 42 " & _
"89 48 70 74 78 07 40 27 " & _
"10 14 004 10 01 16 19 " & _
"20 002 42 21 20 " & _
"32 34 24 32 42 34 30 38 " & _
"58 53 63 57 56 50 " & _
"10 10 13 15 35 13 12 18"
h = findwindow("freewclass", "空当接龙游戏 #617")
for i = 1 to len(s)
c = mid(s, i, 1)
m = 0.1
if c >= "0" and c <= "9" then
a = sendmessage(h, wm_char, asc(c), 0)
else
m = 0.3
end if
m = m + timer: do while timer < m: doevents: loop
next
end sub
发表评论