2015-04-07 33 views
0

我想做一个点击机器人,但我不明白为什么他不工作。运行子作品,但其他没有。 zou能帮助我解释你如何将对象传递给一个过程吗?非常感谢,非常感谢。VBScipt对象内部过程

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

你必须从另一个子内调用你的其他潜艇。 vbscript只是运行您的第一个列出的子。它忽略了“Call”语句。 –

+0

@ jbarker2160,我不同意 - 脚本全局范围内的代码和使用'call'语句都可以很好地处理VBS。 – omegastripes

+0

@omegastripes,那么你有一个更好的答案,为什么它不工作在这个特定的情况下? –

回答

0

只是分配应在所有潜艇bу用于全球范围内的变量对象:

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