Jump to content

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


JohnOne
 Share

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

Link to comment
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.
Link to comment
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.

Link to comment
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 :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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.

Link to comment
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.

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

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

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