2016-11-05 177 views
0

我一直在嘗試點擊網站上的特定按鈕。我終於在這裏尋求幫助。AutoIT |點擊一個Div按鈕|瀏覽器

這是我的整個程序:

#include <ButtonConstants.au3> 
#include <EditConstants.au3> 
#include <GUIConstantsEx.au3> 
#include <StaticConstants.au3> 
#include <WindowsConstants.au3> 
#include <ie.au3> 
#include <MsgBoxConstants.au3> 
#include <GuiEdit.au3> 
#Region ### START Koda GUI section ### Form= 
$Form1 = GUICreate("KingDomLikes Bot", 334, 150, 192, 124) 
$Group1 = GUICtrlCreateGroup("Login", 0, 0, 137, 145) 
$username = GUICtrlCreateInput("Username", 8, 32, 121, 21) 
$password = GUICtrlCreateInput("Password", 8, 64, 121, 21) 
$Login1 = GUICtrlCreateButton("Login", 8, 96, 123, 25) 
GUICtrlCreateGroup("", -99, -99, 1, 1) 
$Group2 = GUICtrlCreateGroup("", 144, 0, 185, 145) 
$repeat = GUICtrlCreateInput("0", 152, 32, 121, 21) 
$Label1 = GUICtrlCreateLabel("Loop", 152, 16, 28, 17) 
$start = GUICtrlCreateButton("Start", 152, 64, 163, 73) 
GUICtrlCreateGroup("", -99, -99, 1, 1) 
GUISetState(@SW_SHOW) 
#EndRegion ### END Koda GUI section ### 
logintosite() 

Func logintosite() 
While 1 
    $nMsg = GUIGetMsg() 
    Switch $nMsg 
     Case $GUI_EVENT_CLOSE 
      Exit 

     Case $Login1 
      Global $oIE = _IECreate("http://addmefast.com/") 

      $username1 = GUICtrlRead($username) 
      $password1 = GUICtrlRead($password) 

      $emailform = _IEGetObjByName($oIE, "email") 
      $usernameform = _IEGetObjByName($oIE, "password") 
      $buttonweb = _IEGetObjByName($oIE, "login_button") 




      _IEFormElementSetValue($emailform, $username1) 
      _IEFormElementSetValue($usernameform, $password1) 
      _IEAction($buttonweb, "click") 

      Case $start 
       _IENavigate($oIE, "http://addmefast.com/free_points/youtube_likes") 
       sleep(2000) 
       For $i = 1 To $repeat 
        Local $oInputs = _IETagNameGetCollection($oIE, "div") 
        For $oInput In $oInputs 
        If $oInput.classname == "btn3" Then _IEAction($oInput, "click") 
        Next 

       Next 

    EndSwitch 
WEnd 
EndFunc 

這是在代碼的最後,我嘗試點擊一個按鈕。該按鈕沒有名稱或ID。

我已經創建了一個賬戶,你們才能夠更好地幫助我: 網站:http://http://addmefast.com/ 郵件:[email protected] 密碼:123456789auto

當您登錄到該網站,點擊在YouTube上喜歡左邊。現在你看到一個名爲like的按鈕,我怎麼點擊它?

Local $oInputs = _IETagNameGetCollection($oIE, "div") 
        For $oInput In $oInputs 
        If $oInput.classname == "btn3" Then _IEAction($oInput, "click") 
        Next 

這不起作用,因爲已經有另一個div(稱爲Add site)。

謝謝!

+1

[的AutoIt可能的複製|單擊一個按鈕(div)](http://stackoverflow.com/questions/40432568/autoit-click-a-button-div) – Samoth

回答

0

與點擊替換您的循環:

  For $a In _IETagNameGetCollection($oIE, "a") 
       If StringInStr(_IEPropertyGet($a, "innerText"), "Like") Then 
        For $i = 1 To $repeat 
         $a.fireEvent("onmousedown") 
         $a.fireEvent("onmouseup") 
         _IEAction($a, "click") 
         _IELoadWait($oIE) 
        Next 
       EndIf 
      Next 

它會點擊的東西...

相關問題