I tried to find information on this, but only found the WM_QUERYENDSESSION function. How can I use this to intercept reboot / shutdown messages?
import win32gui, win32con
msg = win32gui.GetMessage(None, 0, 0)
if msg and msg.message == win32con.WM_QUERYENDSESSION:
print('EXIT')
Here is an example of my code, but when I run it it doesn't handle any actions. and does not intercept shutdown messages