Jump to content

Set Global Timeout


Recommended Posts

Looking to set a global timeout within a For...Next loop. The For...Next I have is reading from a file list and then does a few robotic button pushes. If the robot hangs at any point (unexpected window), it currently requires user interaction to move forward. Is there a way to globally timeout a For...Next statement based on a specified idle time? I've been playing with _Timer_GetIdleTime() in a giant While loop, but that isn't working so well for me.

I've been trying something along the lines of (there has to be a better way):

For $x = 1 to $AttLoc[0]

While _Timer_GetIdleTime() < 60000

;Do Stuff

ContinueLoop

Wend

;Otherwise do this
FileWrite($LOG, "Error Processing (Global Timeout Threshold Exceeded) - "&$inPath&@CRLF)

Next
Link to comment
Share on other sites

Wouldn't it be best to act on the unexpected window?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

Yes, and in time I will add checks for the unexpected windows, but this is a process that needs to run overnight (without interaction from the user). The idea is to log the files with unexpected results and proceed with everything else. I agree that it's avoiding the issue at hand (but this is what has been asked of me). <_<

Link to comment
Share on other sites

Complhex,

I would do it like this (untested)

For $x = 1 to $AttLoc[0]

    if _Timer_GetIdleTime() > 60000 then 

        ;Do your stall routine
        FileWrite($LOG, "Error Processing (Global Timeout Threshold Exceeded) - "&$inPath&@CRLF)

    endif

    ; keep doing whatever you're doing

Next

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

Complhex,

I would do it like this (untested)

For $x = 1 to $AttLoc[0]

    if _Timer_GetIdleTime() > 60000 then

        ;Do your stall routine
        FileWrite($LOG, "Error Processing (Global Timeout Threshold Exceeded) - "&$inPath&@CRLF)

    endif

    ; keep doing whatever you're doing

Next

kylomas

I was thinking that way also, but then realized that the if statement would never be true because the keyboard/mouse would have to be idle for 1 minute before the if statement is hit. I somehow need to include the idle check within the entire For...Next routine and the only way I could think of it was with a while loop.

I also tried this sort of thing, but by invoking the function within the other function, it does not maintain the previous function's variables. It essentially pauses the current running function and calls the other function...so there is no way to move to the next item in the XREF, because it has no idea what the XREF is:

#include

Global $iLimit = 1 ; idle limit in Minutes

For $x = 1 to $AttLoc[0]

AdlibRegister("_CheckIdleTime", 500)

;Do Stuff

Next

Func _CheckIdleTime()
If _Timer_GetIdleTime() > $iLimit * 60000 Then
FileWrite($LOG, "Error Processing (Global Timeout Threshold Exceeded) - "&$inPath&@CRLF)
ContinueLoop
EndIf
EndFunc
Edited by Complhex
Link to comment
Share on other sites

If the error window pops up you would click on a button and the script continues?

If yes, it would be easy to add a function to check every n seconds for the error window. If found click the button and continue where the script stopped when the error window popped up.

It's called: AdLibRegister.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

Complhex,

]

I was thinking that way also, but then realized that the if statement would never be true because the keyboard/mouse would have to be idle for 1 minute before the if statement is hit.

Yes, is this not what you are looking for?

kylomas

edit: I see what you are saying, the for...next loop itsself i stalled.

As water suggested, an ADLIBREGISTER, however, you don't call it in a loop you set it up before the loop. If you are having a problem with variables then declare them outside of func's

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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