0
votes

I have made an AHK script that will take file names from an Excel spreadsheet, open the file in a different program, then export that file to two different formats.
It's working pretty well, except sometimes, the file has some little tweak that needs to be done with it (wrong orientation, hidden layers, etc) that create a popup.
I've tried to program around that by using ifwinexist conditions, so that if I know when a window is SUPPOSED to pop up, the script can deal with it.
The problem I have is that the popup windows can happen at times that I do NOT expect.
So, is there a way to run a thread until the window pops up, closes the window, but then will continue to look for the window?
Thank you

1

1 Answers

0
votes

You are looking for SetTimer, which spawns another thread. The following code checks for the window with partial name Notepad every second (1000ms), and closes it if found.

SetTitleMatchMode, 2
SetTimer, CheckWin, 1000

CheckWin:
    IfWinExist, Notepad
        WinClose, Notepad
    Return