Jump to content

Clicking All Of The Same ObjectName Buttons..?


Recommended Posts

$IE = _IECreate(http://website.com)
$button = _IEGetObjByName($IE, "button")
If Not @error Then 
_IEAction($button, "click")
EndIf
_IELoadWait($IE)

there are more than one of these same Object names ( name="button" ) on a website that i want to click all at once or one after the other, which ever way is possible..

What would the code look like to achieve this..??

Link to comment
Share on other sites

$IE = _IECreate(http://website.com)
$button = _IEGetObjByName($IE, "button")
If Not @error Then 
_IEAction($button, "click")
EndIf
_IELoadWait($IE)

there are more than one of these same Object names ( name="button" ) on a website that i want to click all at once or one after the other, which ever way is possible..

What would the code look like to achieve this..??

If you pass -1 in for the second parameter of _IEGetObjByName you get a collection back instead of a simple object reference. Also, whenever you call taht function, @extended will contain the number of matching objects in the collection and you can refernce them one at a time using the index parameter.

Be aware however, if clicking on the button causes a refresh of the page, all other button references will be invalidated and you must get them again.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

In that case, assuming then buttons come back in the same configuration after the refresh, you could make note of how many there are on the first call and then reference them one by one...

$oIE = _IECreate(http://website.com)
$oButtons = _IEGetObjByName($IE, "button", -1)
$numButtons = @extended
For $i = 0 to $numButtons - 1
    $oButton = _IEGetObjByName($oIE, "button", $i)
    _IEAction($oButton, "click")
    _IELoadWait($oIE)
Next

Dale

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...