Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
As far as I understand, it will be difficult to do this in pure python. You need to use platform-specific tools.
If under Windows, then you can use WinAPI. To access them in python, use the pywin32 package .
The IsIconic() function checks if the window with the specified handle is minimized to the taskbar. Pass it a handle to the window to check.
The GetForegroundWindow() function gets a handle to the window that currently has focus. Not sure if it's a top-level window, or a control with focus (controls are also windows). It returns the handle of the window, if the handle is equal to the desired one, then the desired window is now in focus.
Since you'll need to find out the handle to the desired window, see also FindWindow() . The window class name is more reliable, but harder to find out. The window title can change (for example, in a browser it depends on the current tab), but it is easier to recognize it. In this case, we are talking about the exact match of the window title!
If the title changes, then you should use EnumWindows() , but it's harder to work with.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question