mirror of https://git.48k.eu/ogclient
#1065 windows: add poweroff and reboot
Uses ExitWindowsEx from user32.dll. Library is loaded using ctypes. See https://stackoverflow.com/a/50824776more_events
parent
2dbcd18c06
commit
2e9e5bcb3d
|
@ -7,6 +7,7 @@
|
|||
# (at your option) any later version.
|
||||
|
||||
import os
|
||||
import ctypes
|
||||
import subprocess
|
||||
from subprocess import CalledProcessError
|
||||
import multiprocessing as mp
|
||||
|
@ -18,6 +19,10 @@ from pystray import Icon, Menu, MenuItem
|
|||
from src.ogRest import ThreadState
|
||||
|
||||
|
||||
EWX_POWEROFF=0x00000008
|
||||
EWX_REBOOT=0x00000002
|
||||
|
||||
|
||||
def _create_default_image():
|
||||
"""
|
||||
Creates a default image for the tray icon. Use in case
|
||||
|
@ -69,10 +74,14 @@ class OgWindowsOperations:
|
|||
raise NotImplementedError
|
||||
|
||||
def poweroff(self):
|
||||
user32 = ctypes.WinDLL('user32')
|
||||
systray_p.terminate()
|
||||
user32.ExitWindowsEx(EWX_POWEROFF, 0x0)
|
||||
|
||||
def reboot(self):
|
||||
user32 = ctypes.WinDLL('user32')
|
||||
systray_p.terminate()
|
||||
user32.ExitWindowsEx(EWX_REBOOT, 0x0)
|
||||
|
||||
def shellrun(self, request, ogRest):
|
||||
cmd = request.getrun()
|
||||
|
|
Loading…
Reference in New Issue