Problem
You want to prevent Windows to lock screen locally by inactivity timeouts, like pretending being online and 'alive'
Solution
Use below Python script which simulates dummy mouse moves to pretend online and alive on the system:
import ctypes
from ctypes.wintypes import DWORD, LONG, WORD
import time
ULONG_PTR = ctypes.POINTER(DWORD)
INPUT_MOUSE = 0
MOUSEEVENTF_MOVE = 0x0001
class MOUSEINPUT(ctypes.Structure):
_fields_ = (('dx', LONG),
('dy', LONG),
('mouseData', DWORD),
('dwFlags', DWORD),
('time', DWORD),
('dwExtraInfo', ULONG_PTR))
class _INPUTunion(ctypes.Union):
_fields_ = (('mi', MOUSEINPUT),)
class INPUT(ctypes.Structure):
_fields_ = (('type', DWORD),
('union', _INPUTunion))
LPINPUT = INPUT * 1
pInputs = LPINPUT(INPUT(INPUT_MOUSE, _INPUTunion(mi=MOUSEINPUT(200, 200, 0, MOUSEEVENTF_MOVE, 0, None))))
cbSize = ctypes.c_int(ctypes.sizeof(INPUT))
while True:
ctypes.windll.user32.SendInput(1, pInputs, cbSize)
time.sleep(240)
from ctypes.wintypes import DWORD, LONG, WORD
import time
ULONG_PTR = ctypes.POINTER(DWORD)
INPUT_MOUSE = 0
MOUSEEVENTF_MOVE = 0x0001
class MOUSEINPUT(ctypes.Structure):
_fields_ = (('dx', LONG),
('dy', LONG),
('mouseData', DWORD),
('dwFlags', DWORD),
('time', DWORD),
('dwExtraInfo', ULONG_PTR))
class _INPUTunion(ctypes.Union):
_fields_ = (('mi', MOUSEINPUT),)
class INPUT(ctypes.Structure):
_fields_ = (('type', DWORD),
('union', _INPUTunion))
LPINPUT = INPUT * 1
pInputs = LPINPUT(INPUT(INPUT_MOUSE, _INPUTunion(mi=MOUSEINPUT(200, 200, 0, MOUSEEVENTF_MOVE, 0, None))))
cbSize = ctypes.c_int(ctypes.sizeof(INPUT))
while True:
ctypes.windll.user32.SendInput(1, pInputs, cbSize)
time.sleep(240)
No comments:
Post a Comment