Jump to content

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

Recommended Posts

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()
        If TimerDiff($Timer) >= $ntimeout Then
            Return SetError($ERR_TIMEOUT + 2, 0, 0)

        _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?


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

Share this post

Link to post
Share on other sites

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

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.

Share this post

Link to post
Share on other sites


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 :)

My UDFs and Tutorials:


Active Directory (NEW 2019-08-19 - Version - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Taks Scheduler (NEW 2019-10-09 - Version - Download - General Help & Support - Wiki

ADO - Wiki


Share this post

Link to post
Share on other sites

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


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.

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.

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

  • Create New...