AutoIT |浏览器|单击按钮

时间:2016-11-04 20:29:40

标签: browser login autoit

我在点击按钮时遇到了一些问题。我试着解决过去5个小时的问题,最后在这里结束了。

我试图点击的按钮被称为"喜欢"。这是代码的底部。

代码有什么问题?

#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
                  _IET ($oIE, "Like")

               Next

   EndSwitch
WEnd
EndFunc

我尝试过在网上找到的许多不同的解决方案,但它们都没有真正起作用。

1 个答案:

答案 0 :(得分:0)

  

_IENavigate(ByRef $oObject$sUrl [,$iWait = 1])

您在_IENavigate来电中错过了一个对象参数。

应该是这样的:

  

_IENavigate($ oIE,&#34; http://addmefast.com/free_points/youtube_likes&#34;)

工作代码:

#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")

   EndSwitch
WEnd
EndFunc