我正在尝试制作一个点击机器人,但我无法弄清楚他为什么不工作。运行Sub工作但其他工作没有。你可以帮助我并解释你如何将对象传递给一个程序吗?很多,很多,非常感谢。
Sub run()
set wshshell = wscript.CreateObject("wscript.shell")
wshshell.run "chrome.exe"
wscript.sleep (5000)
WshShell.Sendkeys "https://scrap.tf/raffles"
WshShell.Sendkeys "{ENTER}"
End Sub
Sub find()
wscript.sleep (5000)
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "{ENTER}"
End Sub
Sub enter()
wscript.sleep (5000)
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "{ENTER}"
End Sub
Sub back()
wscript.sleep (5000)
WshShell.Sendkeys "%{LEFT}"
wscript.sleep (5000)
End Sub
Call run
Call find
Call enter
Call back
答案 0 :(得分:0)
只需将应该在所有sub中使用的对象分配给全局范围内的变量:
Set WshShell = wscript.CreateObject("wscript.shell")
Call run
Call find
Call enter
Call back
Sub run()
WshShell.Run "chrome.exe"
WScript.Sleep (5000)
WshShell.Sendkeys "https://scrap.tf/raffles"
WshShell.Sendkeys "{ENTER}"
End Sub
Sub find()
WScript.Sleep (5000)
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "{ENTER}"
End Sub
Sub enter()
WScript.Sleep (5000)
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "{ENTER}"
End Sub
Sub back()
WScript.Sleep (5000)
WshShell.Sendkeys "%{LEFT}"
WScript.Sleep (5000)
End Sub