Jump to content

_IEAction click button


druiddk
 Share

Recommended Posts

Hi,

I hope someone has time to assist me.

Trying to automate clicking some website buttons.

Here is the HTML for the form with the button - the button itself is called BATTLE

<FORM id=app212666255397_form_4aafe9015fb544600381895 method=post><INPUT value=da_DK type=hidden name=fb_sig_locale><INPUT value=1 type=hidden name=fb_sig_in_new_facebook><INPUT value=1253042433.3911 type=hidden name=fb_sig_time><INPUT value=1 type=hidden name=fb_sig_added><INPUT value=1248036675 type=hidden name=fb_sig_profile_update_time><INPUT value=1253131200 type=hidden name=fb_sig_expires><INPUT value=589013527 type=hidden name=fb_sig_user><INPUT value=2.Th9We71uVBphdGDZZu2rKg__.86400.1253131200-589013527 type=hidden name=fb_sig_session_key><INPUT value=cbd58fbda6db2a4ce996586bfb1af4b8 type=hidden name=fb_sig_api_key><INPUT value=212666255397 type=hidden name=fb_sig_app_id><INPUT value=390dbfbfe6c3fa2f8764dc7d6c83029f type=hidden name=fb_sig> <INPUT value="Battle " type=submit name=fight_44496> </FORM></TD></TR></TBODY></TABLE><BR>

The form ID changes everytime - but so far from what i can see this part remains static "app212666255397_form_" - the same with the name the name "fight_" is static but the number after the underscore changes with every refresh.

I have tried using something like:

$Form = _IEFormGetCollection ($oIE, 2)
$Button = _IEFormElementGetCollection($Form, 1)
_IEAction($Button, "click")

But that does not seem to work.

Please note that there are 3 forms on the page and the form im interested in is the 3rd.

Thank you in advance.

Edited by druiddk
Link to comment
Share on other sites

Hi,

I hope someone has time to assist me.

Trying to automate clicking some website buttons.

Here is the HTML for the form with the button - the button itself is called BATTLE

<FORM id=app212666255397_form_4aafe9015fb544600381895 method=post><INPUT value=da_DK type=hidden name=fb_sig_locale><INPUT value=1 type=hidden name=fb_sig_in_new_facebook><INPUT value=1253042433.3911 type=hidden name=fb_sig_time><INPUT value=1 type=hidden name=fb_sig_added><INPUT value=1248036675 type=hidden name=fb_sig_profile_update_time><INPUT value=1253131200 type=hidden name=fb_sig_expires><INPUT value=589013527 type=hidden name=fb_sig_user><INPUT value=2.Th9We71uVBphdGDZZu2rKg__.86400.1253131200-589013527 type=hidden name=fb_sig_session_key><INPUT value=cbd58fbda6db2a4ce996586bfb1af4b8 type=hidden name=fb_sig_api_key><INPUT value=212666255397 type=hidden name=fb_sig_app_id><INPUT value=390dbfbfe6c3fa2f8764dc7d6c83029f type=hidden name=fb_sig> <INPUT value="Battle " type=submit name=fight_44496> </FORM></TD></TR></TBODY></TABLE><BR>

The form ID changes everytime - but so far from what i can see this part remains static "app212666255397_form_" - the same with the name the name "fight_" is static but the number after the underscore changes with every refresh.

I have tried using something like:

$Form = _IEFormGetCollection($oIE, 2)
$Button = _IEFormElementGetCollection($Form, 1)
_IEAction($Button, "click")

But that does not seem to work.

Please note that there are 3 forms on the page and the form im interested in is the 3rd.

Thank you in advance.

So your instance for the Form is correct (2), but how did you decide the button was the second element (1)? It looks more like 11th or 12th. Try something like this:
$Button = 0
$colInputs = _IETagNameGetCollection($Form, "INPUT", -1)
For $oInput In $colInputs
    If StringInStr($oInput.name, "fight_") Then
        $Button = $oInput
        ExitLoop
    EndIf
Next
If IsObj($Button) = 0 Then
    MsgBox(16, "Error", "Failed to find button element 'fight_*'")
    Exit
EndIf

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

So your instance for the Form is correct (2), but how did you decide the button was the second element (1)? It looks more like 11th or 12th. Try something like this:

$Button = 0
$colInputs = _IETagNameGetCollection($Form, "INPUT", -1)
For $oInput In $colInputs
    If StringInStr($oInput.name, "fight_") Then
        $Button = $oInput
        ExitLoop
    EndIf
Next
If IsObj($Button) = 0 Then
    MsgBox(16, "Error", "Failed to find button element 'fight_*'")
    Exit
EndIf

Hi,

Thank you for the effort PsaltyDS! - much appreciated!

I was guessing regarding the element :-/

This code seems to work properly, I hope it can help someone else.

$BattleID =  _StringBetween(_IEBodyReadHTML($oIE), 'type=submit name=fight_', '> </FORM></TD></TR></TBODY></TABLE><BR>')
$Button = _IEFormElementGetObjByName($Form, 'fight_' & $BattleID[0])
_IEAction($Button, "click")
Edited by druiddk
Link to comment
Share on other sites

Too bad you didn't thank PsaltyDS for the work he but into answering you instead of just taking all the credit for yourself.

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

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...