Is there a way to make my Python console application's window flash in the Windows taskbar, to get a user's attention?
My script will be run exclusively in a relatively homogeneous Windows environment, so I don't care about detecting whether a particular API is present, or whether a solution is cross-platform or not (of course cross-platform is better for future reference... but I don't need it for this application).
This is the simplest solution I could come up with:
import ctypes
ctypes.windll.user32.FlashWindow(ctypes.windll.kernel32.GetConsoleWindow(), True )
Flashing the taskbar in Windows is accomplished using the FlashWindowEx
API function (Python API help).
I haven't tried this myself, but it should be possible to call this function from Python using PyWin32 (Python for Windows extensions) that can either by installed manually or by installing ActivePython.
Would this work? http://docs.activestate.com/activepython/2.4/pywin32/win32gui__FlashWindow_meth.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With