Sign in to follow this  
Followers 0
JohhnyAmerica

IE Button Simulated Clicks

7 posts in this topic

Hello,

I'm pretty experienced with AutoIt and HTML, but I have come to a fault.

I'm attempted to simulate a click on a button, but within the HTML, the button has no name, so not only can you not add anything into the address bar, but you can't simulate button clicks with AutoIt. Can someone explain to me how I can simulate a button press on a non-named button without the Send function while also using the IE.au3 #include?

Thanks Alot,

Johnny America

Share this post


Link to post
Share on other sites



If the button doesnt have a name you have to use its ID to referance it in IE.au3 , You can find the ID by using a DOM inspector


Firefox's secret is the same as Jessica Simpson's: its effortless, glamorous style is the result of — shhh — extensions!

Share this post


Link to post
Share on other sites

$oButton = _IETagNameGetCollection($oIE, "button", 0-based-index)

_IEAction($oButton, "click")

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

Share this post


Link to post
Share on other sites

I'm sorry, neither techniques have worked.

I used a dom inspector, the button had no id.

The script Dale posted also did not work.

Here is a sample piece of HTML that uses the technique I'm trying to break.

<form action='buttonpushed.phtml' method='get'>
<input type='submit' value='Push this button!'>
</form>

It links to another site, but you have to have pressed the button in order to gain access to it.

Thanks,

Johnny America

Share this post


Link to post
Share on other sites

Ok heres another solution using the buttons value, see how you go with this

#include <IE.au3>
    _IEErrorHandlerRegister ("MyErrFunc1")
    $oIE = _IEAttach ("Autoit Forums", "Title")  ; change to your page or use IEcreate
    $oDoc = _IEDocGetObj ($oIE)
    $forms = _IEFormGetCollection ($oDoc)
        For $form in $forms
            $frmobjs = _IEFormElementGetCollection ($form)
                For $frmobj in $frmobjs
                    $value = $frmobj.value
                    if $value = "Push this button!" Then
                        $butname = $frmobj.name  ; might have to use $frmobj.id instead
                        $oButton = _IEFormElementGetObjByName($form,$butname)
                        _IEAction($oButton, "click")            
                        endif
                    
                    next

next
func MyErrFunc1()
 ConsoleWrite($frmobj.value)
 EndFunc

Firefox's secret is the same as Jessica Simpson's: its effortless, glamorous style is the result of — shhh — extensions!

Share this post


Link to post
Share on other sites

Ok heres another solution using the buttons value, see how you go with this

#include <IE.au3>
    _IEErrorHandlerRegister ("MyErrFunc1")
    $oIE = _IEAttach ("Autoit Forums", "Title")  ; change to your page or use IEcreate
    $oDoc = _IEDocGetObj ($oIE)
    $forms = _IEFormGetCollection ($oDoc)
        For $form in $forms
            $frmobjs = _IEFormElementGetCollection ($form)
                For $frmobj in $frmobjs
                    $value = $frmobj.value
                    if $value = "Push this button!" Then
                        $butname = $frmobj.name  ; might have to use $frmobj.id instead
                        $oButton = _IEFormElementGetObjByName($form,$butname)
                        _IEAction($oButton, "click")            
                        endif
                    
                    next

next
func MyErrFunc1()
 ConsoleWrite($frmobj.value)
 EndFuncoÝ÷ Ûú®¢×jÈ^¯l{¦¦W¬¥w
+©Ýè¬v§Ê&yö§s+ax,mçºÇ¡z¬j
(véÝz»-jwb
¶8ÄáyìZ^"¯{*.v'gßÛp¢¹yÆ®±ì¨ºÆ¢vØ^¡¸Þrܨ»§µçm¡ÉbrJ'Á«ªê-DÓ8Ú®¢Ü!jܨºÈhÂ)íáÓ0»'^µ¦è½è¬ZtÌ,Lã[ºÚÚ¶«hZ+I^éí"zn¶Ö ½êòv'ßz·§µ»­"éÝz»-jwmç(û¬Èß×lº²Ü¨ºZ(«mçîËb¢{Z+g­
eyËb¢v§t¢¹¹¹¢µ©Ýz+az²
·µê+ @-µ§!jÈZ²«²è zËlNÅ©©ë-êÞÂ)e²0Ê¡£³+aÇ·~Øb²+-çâ®Ë_¢¹¨Ø^¥¨Ê«±Êâ¦×·²È¦¦W±«­¢+ØÀÌØí½%ô}%ÑÑ  ÅÕ½Ðí¥¹ÍÉе¥¹¹¥¹½µÉ½ÝÍȵݥ¹½ÜµÑ¥Ñ±µ¡ÉÅÕ½Ðì¤(ÀÌØí½½É´ô}%½ÉµÑ
½±±Ñ¥½¸ ÀÌØí½%°À¤)}%½ÉµMÕµ¥Ð ÀÌØí½½É´¤

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

Share this post


Link to post
Share on other sites

BTW my code will fail on most sites using frames :-(

Hasher's example should work and he is doing some fancy things because he has a good understanding of the DOM

Only because of Dale , IE.au3 and MSDN . Dale is an IE god ;-)


Firefox's secret is the same as Jessica Simpson's: its effortless, glamorous style is the result of — shhh — extensions!

Share this post


Link to post
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
Sign in to follow this  
Followers 0