Sign in to follow this  
Followers 0
Olsson

_IE Error, FormElement loop

9 posts in this topic

#1 ·  Posted (edited)

Hi guys!

I get this weird error when I try to execute this function;

The script reads from a file, tAttack.txt - Inserts the values into the form.

When all the 13 form values has been filled, submit the form.

If we can find more text to read - repeat!

Main Script - When button X is pressed:

a2bU()
        $i = 0
        $p = 0
        $openAttack = FileOpen("tAttack.txt", 0)
        $oForm = _IEFormGetObjByName ($oIE, "snd")
            While 1             
                $readAttack = FileReadLine ($openAttack, $i)
                        If $readAttack = "-" Then
                            MsgBox (1,"", "HAJ", 0)
                            ExitLoop
                        Else
                            If @error = -1 Then ExitLoop
                        EndIf
                                            
                _IEFormElementSetValue ($a2b[$p], $readAttack)
                If $p = 13 Then                 
                    _IEFormSubmit($oForm, 1)
;~                  _IEFormImageClick ($oIE, "s1", "name")
                    
                    $p = 1
                    $i = $i + 1
                Else
                    $i = $i + 1
                    $p = $p + 1
                EndIf
            WEnd

a2bU - Function

_IENavigate ($oIE, "http://speed.travian.se/a2b.php")
        
        $oForm = _IEFormGetObjByName ($oIE, "snd")
        $a2b[1] = _IEFormElementGetObjByName ($oForm, "t1");- A
        $a2b[2] = _IEFormElementGetObjByName ($oForm, "t2");- B
        $a2b[3] = _IEFormElementGetObjByName ($oForm, "t3");- C
        $a2b[4] = _IEFormElementGetObjByName ($oForm, "t4");- D
        $a2b[5] = _IEFormElementGetObjByName ($oForm, "t5");- E
        $a2b[6] = _IEFormElementGetObjByName ($oForm, "t6");- F
        $a2b[7] = _IEFormElementGetObjByName ($oForm, "t7");- G
        $a2b[8] = _IEFormElementGetObjByName ($oForm, "t8");- H
        $a2b[9] = _IEFormElementGetObjByName ($oForm, "t9");- I
        $a2b[10] = _IEFormElementGetObjByName ($oForm, "t10");- J
        $a2b[11] = _IEFormElementGetObjByName ($oForm, "t11");- K
        
        $a2b[12] = _IEFormElementGetObjByName ($oForm, "x");- X-Pos
        $a2b[13] = _IEFormElementGetObjByName ($oForm, "y");- Y-Pos

I get this error;

G:\Program\AutoIt3\Include\IE.au3 (1470) : ==> The requested action with this object has failed.:
$o_object.fireEvent("onchange")

Update:

It works when there are 13 rows in tAttack.txt - Not when 26, when it loops!

Edited by Olsson

Share this post


Link to post
Share on other sites



Try this...

_IEFormElementSetValue ($a2b[$p], $readAttack, 0)

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

There 's just not enough info here, I can't tell without all parts if you are looping without re-reading the form after..

If $p = 13 Then

cause that might be

If $p = 13 Or $p = 26 Then ????

anyways after clicking you need to get the new form info

good luck

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks Valuater! Think that did the trick! (post #2) - I gotta test it properly.

Edited by Olsson

Share this post


Link to post
Share on other sites

There 's just not enough info here, I can't tell without all parts if you are looping without re-reading the form after..

If $p = 13 Then

cause that might be

If $p = 13 Or $p = 26 Then ????

anyways after clicking you need to get the new form info

good luck

8)

The Form is 13 Inputs, when it has added the data into those 13 inputs, Submit form, then restart the counter, count up to 13 and repeat.

Share this post


Link to post
Share on other sites

Case $go_btn
        a2bU()
        $i = 0
        $p = 0
        $openAttack = FileOpen("tAttack.txt", 0)
        $oForm = _IEFormGetObjByName ($oIE, "snd")
            While 1             
                $readAttack = FileReadLine ($openAttack, $i)
                        If $readAttack = "-" Then
                            MsgBox (1,"", "HAJ", 0)
                            ExitLoop
                        Else
                            If @error = -1 Then ExitLoop
                        EndIf
                                            
                _IEFormElementSetValue ($a2b[$p], $readAttack, 1)
                If $p = 13 Then
                    _IEFormElementRadioSelect ($oForm, "4", "c", 1, "byValue")
                    Sleep (500)
                    _IEFormSubmit($oForm, 1)
                    Sleep (250)
                    _IEFormImageClick ($oIE, "s1", "name")
                    $i = $i + 1
                    $p = 0
                    a2bU()
                Else
                    $i = $i + 1
                    $p = $p + 1
                EndIf
            WEnd

Now this is the renewed code - But It does contain a problem, sometimes it submits the same form values twice or thrice? Can anyone spot the problem?

Thanks,

Olsson

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

If ever you are having strange peoblems with code that includes _IEFormSubmit, as suggested in the function remarks, I recommend you disable the implicit _IELoadWait called by that function and call it manually. Therefore, replace

_IEFormSubmit($oForm, 1)

with

_IEFormSubmit($oForm, 0)

_IELoadWait($oIE)

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

Share this post


Link to post
Share on other sites

Therefore, replace

_IEFormSubmit($oForm, 1)

with

_IEFormSubmit($oForm, 0)

_IELoadWait($oIE)

That fixed another problem I had, heh. Well, It still does loop the same values twice or thrice, just randomly. I can't figure out why!

Share this post


Link to post
Share on other sites

Still wondering over post #8, any ideas?

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