Sign in to follow this  
Followers 0
Hyflex

Running two tasks at the same time & terminating the main task?

6 posts in this topic

Hi Guys,

I've got the following AutoIt Window Info information but I'm unsure how how to handle error windows correctly....

>>>> Window <<<<
Title: Bas Assist
Class: #33392
Position: 395, 245
Size: 242, 126
Style: 0x94C801C5
ExStyle: 0x00010101
Handle: 0x000F0B1E

>>>> Control <<<<
Class: Button
Instance: 1
ClassnameNN: Button1
Name:
Advanced (Class): [CLASS:Button; INSTANCE:1]
ID: 2
Text: OK
Position: 153, 68
Size: 75, 23
ControlClick Coords: 26, 8
Style: 0x50030000
ExStyle: 0x00000004
Handle: 0x000C09C8

>>>> Mouse <<<<
Position: 577, 343
Cursor ID: 0
Color: 0xD4D0C8

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
OK
Error during opening. Please try again.


>>>> Hidden Text <<<<

I'm trying to make a script automate a length task but now and again we get random error popups from the program we're using, they can be anywhere and I'd rather not have to put window checks everywhere to terminate the script but instead have some sort of way to catch the window and terminate the function that is currently running and instead run a different one...

I think the thing I'm looking for is two threads...? I'd rather not have a separate script running checking for the error popup, killing the script and then restarting it or startng a different one.

I'm also looking for information on how to check the Visible text, I want to do: If visibletext contains "Error during opening." then....

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You can do an:

AdLibregister

...create a function that checks for the error window...if present, do what must be done...you can even call your script again, and exit the current run.  This is much easier than having a second process.

If it only occurs within 30 seconds of some action, then perform the action, do the AdlibRegister, and then unregister it, after the 30 seconds.

Window text:

WinGetText
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

 

You can do an:

AdLibregister

...create a function that checks for the error window...if present, do what must be done...you can even call your script again, and exit the current run.  This is much easier than having a second process.

If it only occurs within 30 seconds of some action, then perform the action, do the AdlibRegister, and then unregister it, after the 30 seconds.

Window text:

WinGetText

Hmm that looks perfect for this situation but I can't see in the docs how to either exit the current run...

Share this post


Link to post
Share on other sites

Exit the run:

Exit

Look up "Command Line Parameters" in the help file for examples of calling a script...or you can compile, and call as an exe.


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

Exit the run:

Exit

Look up "Command Line Parameters" in the help file for examples of calling a script...or you can compile, and call as an exe.

Oh you meant exiting the entire script, I was meaning that function only... kind of hard to explain when I'm not sure on most of the functions.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Something like this?

Code()

Func Code()
    While 1
        Local $RandomNumber = Random(0, 5, 1)
        If $RandomNumber = 4 Then Other_Code($RandomNumber)
        MsgBox(4096, $RandomNumber, "Something is being done", 1)
        Sleep(100)
    WEnd
Endfunc

Func Other_Code($RandomNumber)
    MsgBox(4096, $RandomNumber, "Sometimes it happens, and there is an error..")
    If MsgBox(4 + 4096, $RandomNumber, "Continue?") = 6 Then Code()
    Exit
EndFunc

To check for visible text, see the WinGetText function.

edit: oh I see it's already been mentioned and you've already found that function..

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

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  
Followers 0