JohnOne

Weird problem freaking me out. (stuck in loop that code already exited)

7 posts in this topic

#1 ·  Posted (edited)

I cannot get my head around why this could possible happen, and would love some fresh thoughts on it if you have the time.

Here is the part of code where I'm flummoxed..

; Wait for camera button available
    Local $o_Camera_Button = 0
    $Timer = TimerInit()
    Do
        If TimerDiff($Timer) >= $ntimeout Then
            Return SetError($ERR_TIMEOUT + 2, 0, 0)
        EndIf

        _IEAction($o_Text_Field, "focus")
        _IEAction($o_Text_Field, "click")

        $o_Camera_Button = _IEGetObjById($o_IE, "js_2")
        Sleep(100) ; TrayIconDebug reports that the code is executing this line;
    Until IsObj($o_Camera_Button)

    _IEFormElementSetValue($o_Text_Field, $sDescription); this line gets executed
    Beep(800, 120);and so does this, its the only Beep in the code
    Return 1

This is freaking me out because my code has no loop, it just goes through the code, quits IE and exits.

I've commented the wierdness.

The script appears to be stuck in a loop from which it has seemingly exited, I think it's exited the loop because the line

"_IEFormElementSetValue($o_Text_Field, $sDescription)" does its job, and it the only such task in my code.

I hear the BeeP() after that, and that is the only beep in my code. However The debug says I'm stuck in the preceding loop.

It's winding me up.

What comes after this is a Button on webpage is clicked (in the next function) which opens a "Choose File to Upload" dialogue box.

But obviously It cannot have anything to do with the loop madness in the function before it, can it?

EDIT:

When I say "my code has no loop" I mean script keep alive main loop. once a function loop has exited, there is no way for it to enter that loop again, all functions are called but once. They succeed or the whole script is exited.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

clicks in IE don't return until you close dialogs opened by the browser

So, you can start a new script to actually do the click, or do the focus and controlsend spacebar at the browser that opens the dialog, or start another script prior to the click to wait for the popup and fulfill it...then your primary script will proceed

Edited by jdelaney
1 person likes this

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

I pondered that for quite some time, but what is getting clicked in that code is just a text field, which gives focus to it, the camera button becomes visible, some text in entered in the text field , the beep is executed and the function returns 1.

The next function clicks the camera button where the dialogue is opened, that occurs so I must have returned from above code.

However I'm stuck at dialogue then, but according to TrayIconDebug I have not even clicked the camera button, I'm still in the previous function.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

BTW:

Could you please give meaningful titles to your threads? So we do not have to open your thread just to know what you are talking about :)

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

jdelaney's suggestion of running another script fixes the issue.

Cheers.

But it's still freaking me out why it happens.

Can only conclude a bug in TrayIconDebug option.

Do, not have time to try to reproduce though.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

you could also try to use the other solution of the controlsend proposed by jdelaney, something like this  ControlSend($hIE, "", "", "{ENTER}") instead of the external script in a way like in >this example related to a solution to a problem similar to the one you are talking about here.

1 person likes this

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

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