Vbscript VBScipt对象内部过程

Vbscript VBScipt对象内部过程,vbscript,Vbscript,我想做一个点击机器人,但我不明白他为什么不工作。运行子工程,但其他子工程不运行。邹能帮我解释一下如何将对象传递到过程中吗?非常非常非常感谢 Sub run() set wshshell = wscript.CreateObject("wscript.shell") wshshell.run "chrome.exe" wscript.sleep (5000) WshShell.Sendkeys "https://scrap.tf/raffles" W

我想做一个点击机器人,但我不明白他为什么不工作。运行子工程,但其他子工程不运行。邹能帮我解释一下如何将对象传递到过程中吗?非常非常非常感谢

    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

只需将所有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

您必须从另一个子系统中调用其他子系统。vbscript只是运行您列出的第一个子系统。它忽略了
call
语句。@jbarker2160,我不同意-脚本全局范围内的代码和使用
call
语句都可以与VBS配合使用。@omegastripes,那么您就有了一个更好的答案,说明在这种特定情况下,它为什么不起作用?