AutoIt: Detect windows which are undetectable by AutoIt Window Info


At work, we use a Java based system and although I used AutoIt to automate keystrokes many times – and it works – however there are times where I found it difficult to tune my scripts to understand when it should wait for a special screen to pop up before it continues executing – AutoIt Window Info can’t help it.

Let’s take this example:

There’s a file with 300 records and I want AutoIt to read from the file and input the values in the respective fields on the system (I did this because the system uploader crashed many times).

I certainly was monitoring how the automation script worked and what are the unexpected results mostly due to the short $delay value I set which controls the wait time in ms between entering values into the system fields.

I also tried to set $delays variable to the maximum time I think is sufficient and won’t slow up my script too – and it fails at the rate of 1 record/15 records or just at 70/300 and repeats at other points because of unexpected lags! I wanted all records to be in the same order as in the input file.

So I thought of a own developed technique given the following:

  1. I know that the total execution time of the script is something that I can sit, relax and monitor and won’t waste much time of mine.
  2. No pop up windows will appear during the execution time (no interception and I’m also there in case I need to switch back to the system window manually).
  3. System special window which I want my script to wait for always in appears in the same position – in other words (x, y) pixel coordinates won’t change unless I do move the window and I won’t do it.

Because all of the above satisfies every time:

  1. I took a screenshot of the whole screen when the system special window appeared.
  2. I extracted a portion of the window’s title from the screenshot (serves as an identifier to the window), saved it as JPEG image and calculated it’s MD5 checksum value which will never change
  3. I noted the (x, y) pixel coordinates of the region I extracted in point #2
  4. I inserted a similar code of the one in this topic to my script to tweak it into waiting for that special window when it appears (basically takes a screenshot of the same size as in point #2 starting at the same (x, y) coordinates, saves it as JPEG, calculates the MD5 hash and compares it to the fixed known MD5 value from point #2
  5. The script will take screenshots every 250 ms which was ok and fast in my situation

Here’s the script that I used just to test if my technique worked and I used BMP format at that time:

* This is the BMP checksum image (a region of my Windows 7 background at the time of test at 1920×1080 resolution)


I hope this helps you or your friends. If you make and sell AutoIt programs then perhaps this could work for one of your clients.

All the best

2 thoughts on “AutoIt: Detect windows which are undetectable by AutoIt Window Info

Leave a Reply