Win32’s FindWindow() can find a window having the title of “Untitled – Notepad”, but what if I just want to find a Notepad window but don’t know whether it is “try.bat – Notepad” or some other file name on the title bar?
It seems that if the title is passed in a NULL value, then any window will be returned, but only one window is returned, so there is no way to grep for the title using regular expression.
(I am doing this using Ruby’s Win32API)
I would follow Eric’s advice to use EnumWindows. You can provide Ruby callbacks to Windows API functions through win32-api. Here’s an example that was trivially modified from the sample in the win32-api README: