Sign in to follow this  
Followers 0
tomasvorobjov

WinWaitActive with unknown title

6 posts in this topic

#1: I have a script that does stuff to input (from AutoIt), then continues to process new input and so on... Everything works fine, but sometimes the input processing (by my application) will fail due to various reasons (API temporarily inaccessible, input was not valid etc). Therefore, I need to determine when an error occurs to handle it.

If everything works fine, I can do WinWaitActive( "My Application" ) to know when to continue, however, the errors produce a "popup" with unpredictably random messages. How can I simply check for when the next window becomes available/ready, no matter what the title is and then use the title to determine if my previous action was successful or not. That is, i'd like to do the following

process input
(wait until "My Application" is available) or (wait until "Error" is available)
- handle error
(wait until "My Application" is available)
process input

#2: In a similar manner, when "My Application" starts I use WinWaitActive( "My Application" ) to determine when I can send input to it to start processing. However, occasionally (which is again, unpredictable) a pop-up will show up (with some title). How can I check for this happening. Basically, in pseudo code I'd like to do this:

(wait until "My Application" is available) or (wait until "Popup" is available)
- handle the popup
(wait until "My Application" is available)

Thank you

Share this post


Link to post
Share on other sites



A time consuming way is to wait for the error window to pop up for a limited time.

Use WinWaitActive ("title" , "text" , timeout)

Another possible way is to start a second script that checks for the popups and does what is needed to click them away. My OutlookEX UDF uses this approach with the _OL_Warnings script started by function _OL_Open.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - 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

If you don't know the title of the unpredictable popup window, then perhaps you could test the active window title, compair it to the main program window title and close the current active window if the titles do not match. This approach does have some serious drawbacks to consider. If a window from a different program appears then you may not wish to automatically close it. For example the window could contain an important windows message. Just some thoughts.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Another solution:

Get a list of all Windows using function WinList

For each entry in the returned array use the handle to call WinGetProcess

If the processID is the same as the processID of the running script (@AutoItPID) you know it's a window of the running program

Close all windows which don't have the required title

Edit:

Found this with the code ready to run.

Edited by water
1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - 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

Hi czardas,

thanks for the compliment.

A glass of Lagavulin just cleared my brain. Slàinte!


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - 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

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