AutoIT |单击按钮|浏览器 [英] AutoIT | Click On A Div Button | Browser

查看:934
本文介绍了AutoIT |单击按钮|浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图点击网站上的特定按钮。



这是我的整个程序:

  #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登录,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 ,28,17)
$ start = GUICtrlCreateButton(Start,152,64,163,73)
GUICtrlCreateGroup(,-99,-99,1,1)
GUISetState (@SW_SHOW)
#EndRegion ### END Koda GUI部分###
logintosite()

Func logintosite()
While 1
$ nMsg = GUIGetMsg()
切换$ nMsg
案例$ GUI_EVENT_CLOSE
退出

案例$ Login1
全局$ 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)
对于$ oInput在$ oInputs
如果$ oInput.classname ==btn3然后_IEAction($ oInput,click)
Next

下一页

EndSwitch
WEnd
EndFunc


b $ b

这是在代码的结尾,我想点击一个按钮。该按钮没有名称或ID。



我已经为您创建了一个帐户,以便能够更好地协助我:
网站: http:// http://addmefast.com/
邮件:danielssah8 @ gmail .com
密码:123456789auto



当您登录网站时,请点击左侧的youtube赞。

  Local $ oInputs = _IETagNameGetCollection($ oIE,div )
For $ oInput In $ oInputs
如果$ oInput.classname ==btn3然后_IEAction($ oInput,click)
接下来



这不起作用,因为已有另一个div(称为添加网站)。



感谢!

解决方案

将点击替换为您的循环:

 对于$ a在_IETagNameGetCollection($ oIE,a)
如果StringInStr(_IEPropertyGet($ a,innerText),Like)然后
For $ i = 1 To $ repeat
$ a.fireEvent(onmousedown)
$ a.fireEvent(onmouseup)
_IEAction($ a,click)
_IELoadWait ($ oIE)
Next
EndIf
Next

将点击某事...


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.

I have created an account for you guys to be able to assist me better: Website: http://http://addmefast.com/ Mail: danielssah8@gmail.com Password: 123456789auto

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:

           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

And it will click on something...

这篇关于AutoIT |单击按钮|浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆