How can I bring a window into focus programmatically on Mac using Python?
I'm looking for a Python library (or, if none exists, a non-Python approach would be OK too) that will let me bring a window into focus on Mac programatically.
On windows, I can do this with the win32gui library's SetForegroundWindow function. Is there a Mac equivalent?
Some candidate libraries I've looked at are
pygetwindow. The former doesn't offer the desired functionality, and the later is only for windows.
I've found I can list the available windows using Quartz like this:
from Quartz import CGWindowListCopyWindowInfo, kCGNullWindowID, kCGWindowListOptionAll window_info = CGWindowListCopyWindowInfo(kCGWindowListOptionAll, kCGNullWindowID)
However, I've been unable to find a way to programmatically switch to a selected window. I'm running MacOS Mojave 10.14.5.