I have been trying to click on a specific button on a website. I have finally concluded to ask for help here.
This my whole program:
#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
It's at the end of the code, im trying to click on a button. The button does not have a name or id.
When you login to the site, click on youtube likes to the left. Now you see a button called like, how do I click that?
Local $oInputs = _IETagNameGetCollection($oIE, "div")
For $oInput In $oInputs
If $oInput.classname == "btn3" Then _IEAction($oInput, "click")
Next
This do not work because there is already another div (called Add site).
Thanks!
Replace your Loop with the click with:
And it will click on something...