Wake Windows PC from sleep in Python 2.7

后端 未结 2 1447
有刺的猬
有刺的猬 2021-01-22 07:35

I have a script that will put the system to sleep in the middle of it. Is there any way to make that script wake the system up and then continue running?

I have read man

2条回答
  •  生来不讨喜
    2021-01-22 07:58

    It depends on how you're putting the system to sleep. If using SetSuspendState (with the last argument being FALSE to allow wake-up events), then you can schedule a future wake-up using CreateWaitableTimer followed by SetWaitableTimer.

    The respective Python implementation is quite easy using ctypes or, if you want something more pythonic, pywin32.

    Hope it helps!

提交回复
热议问题