Python检测Windows 10中的 sleep 模式

标签 python windows python-3.x

我想知道我是否可以在计算机休眠之前启动 python 程序中的函数或方法,这与

def f():
    if about_to_sleep:
        do_stuff
    else:
        do_some_other_stuff

可以在 windows 10 中运行

最佳答案

如果您不介意编写一个在后台运行的小型 C++ 应用程序,它可以在检测到计算机进入休眠状态时调用您的 python 脚本。

看看: Qt detect when computer goes into sleep?

关于Python检测Windows 10中的 sleep 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42650968/

相关文章:

python - 如何通过脚本从 XMI 正确导入一个完整的 Enterprise Architect 项目?

python - 如何触发 "except"?

windows - RescueTimes 阻止是如何工作的?

python - 为什么在相同但以不同方式创建的嵌套字典中将值分配给键会导致不同的结果?

python - 如何将python输出发送到 Telegram channel 而不是组和gmail电子邮件组

python - tkinter 在 python 中渲染错误的 RGB 阴影

python - 我什么时候应该在 python 中使用 uuid.uuid1() 和 uuid.uuid4()?

javascript - 使用 jquery 和 javascript 改变图像的大小

.net - 实现托管属性处理程序 Shell 扩展的正确方法是什么?

Python chr() 解释