Jump to content
Sign in to follow this  
Complhex

Set Global Timeout

Recommended Posts

Complhex

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

Share this post


Link to post
Share on other sites
water

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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
Complhex

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

Share this post


Link to post
Share on other sites
kylomas

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

Share this post


Link to post
Share on other sites
Complhex

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

Share this post


Link to post
Share on other sites
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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
kylomas

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

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  

×