当前位置: 代码网 > it编程>编程语言>其他编程 > VBA解决Windows空当接龙的617局

VBA解决Windows空当接龙的617局

2024年05月15日 其他编程 我要评论
windows的自带游戏空当接龙,其中第617局是比较难解的,需要尝试的次数比较多,而且经常忘记解法和步骤。原本希望使用autoit或autohotkey、aauto一类的工具,写一段自动化脚本快速解

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

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com