0

My question is similar to this one: Get HWND of each Window? But I need to find windows that belong to a specific program, I'm not familiar with ctypes or win32gui. Can someone help me?

martineau
  • 119,623
  • 25
  • 170
  • 301
  • Seems like you could use `win32gui.GetWindowText(hwnd)` to get the title of each window and see if it starts with the name of the specific program (or contains it somewhere, I'm not sure it's always first). – martineau Aug 15 '17 at 03:50
  • Look into enumerating the windows on the current desktop via [`EnumDesktopWindows`](https://msdn.microsoft.com/en-us/library/ms682615) and mapping a Window handle to a Process ID via [`GetWindowThreadProcessId`](https://msdn.microsoft.com/en-us/library/ms633522). On the other side of this, create a snapshot via [`CreateToolhelp32Snapshot`](https://msdn.microsoft.com/en-us/library/ms682489) to build a list of Process IDs for a given executable name. – Eryk Sun Aug 15 '17 at 06:09
  • If you need to be more specific, open a handle to the process via [`OpenProcess`](https://msdn.microsoft.com/en-us/library/ms684320) and get the fully-qualified path via [`QueryFullProcessImageName`](https://msdn.microsoft.com/en-us/library/ms684919). Then call [`GetFileVersionInfoEx`](https://msdn.microsoft.com/en-us/library/aa969434) to verify the file description and version. – Eryk Sun Aug 15 '17 at 06:11

0 Answers0