2016-02-12 130 views
0

我想製作一個VBS文件,當你打開它時,會在Google Chrome中啓動一個標籤,然後點擊一個按鈕。在這種情況下[PLAY]。製作一個VBS文件點擊一個按鈕

這裏是我的腳本:

Dim iURL 
Dim objShell 

iURL = "http://www.roblox.com/games/292439477/NEW-GUNS-Phantom-Forces-Beta" 

set objShell = CreateObject("Shell.Application") 
objShell.ShellExecute "chrome.exe", iURL, "", "", 1 
WScript.Sleep(3000) 
Document.getElementById("MultiplayerVisitButton").Click() 

如果任何人有一個方法,使其實際點擊它,將是不錯然而,這是行不通的。

+0

腳本和方法的金額嘗試:24的量,已經工作:0 – Luniz

回答

0

它不會顯示爲您已將Chrome文檔傳遞到您的Document對象中。

嘗試增加兩個引用:Microsoft Internet控制和Microsoft HTML對象庫,然後:

Dim iURL 
Dim objShell 
Dim Document As HTMLDocument 
Dim Elem As IHTMLElement 
Dim Elements As IHTMLElementCollection 

iURL = "http://www.roblox.com/games/292439477/NEW-GUNS-Phantom-Forces-Beta" 

Set objShell = CreateObject("Shell.Application") 
objShell.ShellExecute "chrome.exe", iURL, "", "", 1 
WScript.Sleep (3000) 
Document = objShell.HTMLDocument 
Elements = Document.getelementsbyClassName("rbx-btn-primary-lg") 
For Each Elem In Elements 
    If Elem.innerText = "Play" Then 
     Elem.Click 
     Exit For 
    End If 
Next 
+0

見修訂的答案。 –

+0

我非常非常新的VBScript,我應該改變行3,4,和5的東西?如果是的話,請幫我在這裏,也什麼叫」 意味着接受 ,如果你已經通過了Chrome的文件到您的文檔對象時,它不會出現 嘗試增加兩個引用:Microsoft Internet控制和Microsoft HTML對象庫「 – Luniz

+0

您可能想使用」Selenium Wrapper「來有效地自動化Chrome。 [鏈接](http://www.makeuseof.com/tag/how-to-automate-firefox-or-chrome-with-vba-and-selenium/) –