Jump to content

WinWaitActive with unknown title


Recommended Posts

#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

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

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.

Link to comment
Share on other sites

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

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

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

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