[Python] How to create Python event that should invoke on before windows sleep mode

Discussão em 'Python' iniciado por Stack, Julho 9, 2025.

  1. Stack

    Stack Membro Participativo

    I need Python event that should log present time into a file when windows receive sleep request. Below is my main code,

    import subprocess

    # Here code required to log the time at which system going to sleep
    command = 'Sleep.py'
    # Some usefull stuff
    if subprocess.call(command, shell=True):
    print 'Success'
    else:
    print 'Fail'


    Below is 'Sleep.py' code,

    import os
    os.system("Rundll32.exe Powrprof.dll,SetSuspendState Sleep")


    Can any one please provide solution to this

    Continue reading...

Compartilhe esta Página