#3011: Listen to WM_ENDSESSION on Windows
------------------------------+--------------------
Reporter: joeyvh | Owner:
Type: feature-request | Status: new
Priority: minor | Milestone: 1.3.15
Component: GTK UI | Version: 1.3.14
Resolution: | Keywords:
------------------------------+--------------------
Changes (by Cas):
* version: other (please specify) => 1.3.14
* component: Unknown => GTK UI
Comment:
Collated information for ongoing dev...
* [https://msdn.microsoft.com/en-us/library/ms700677(v=vs.85).aspx
Application shutdown documentation]
* [https://msdn.microsoft.com/en-
us/library/windows/desktop/aa376890(v=vs.85).aspx WM_QUERYENDSESSION]
* [https://msdn.microsoft.com/en-
us/library/windows/desktop/aa376889(v=vs.85).aspx WM_ENDSESSION]
* [https://msdn.microsoft.com/en-
us/library/windows/desktop/aa376877(v=vs.85).aspx
ShutdownBlockReasonCreate]
* [http://stackoverflow.com/q/31374339/175584 SO - Process WM_ENDSESSION,
WM_QUERYENDSESSION]
* [http://stackoverflow.com/q/520910/175584 SO - simulate Windows shutdown
for debugging]
Code to test pid handling messages:
{{{#!python
from win32con import WM_QUERYENDSESSION
from win32gui import EnumWindows, GetClassName, IsWindowEnabled,
IsWindowVisible
from win32process import GetWindowThreadProcessId
def get_hwnds_for_pid(pid):
def enumwins_cb(hwnd, hwnds):
if IsWindowVisible(hwnd) and IsWindowEnabled(hwnd):
# print(GetClassName(hwnd), GetWindowThreadProcessId(hwnd)[1])
if pid == GetWindowThreadProcessId(hwnd)[1]:
hwnds.append(hwnd)
return True
hwnds = []
EnumWindows(enumwins_cb, hwnds)
return hwnds
def shutdown_pid(pid):
win32api.PostMessage(get_hwnds_for_pid(pid)[0], WM_QUERYENDSESSION)
}}}
--
Ticket URL: <http://dev.deluge-torrent.org/ticket/3011#comment:6>
Deluge <http://deluge-torrent.org/>
Deluge Project
--
You received this message because you are subscribed to the Google Groups
"Deluge Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/deluge-dev.
For more options, visit https://groups.google.com/d/optout.