目标:Windows自动睡眠监控器,检测笔记本长时间无用户行为操作后进入睡眠模式以节省电量
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Windows自动睡眠监控器
检测笔记本长时间无用户行为操作后进入睡眠模式以节省电量
"""
import os
import time
import threading
import logging
import subprocess
from datetime import datetime
from typing import Dict, Any
from ctypes import Structure, c_uint, windll, byref
from ctypes.wintypes import DWORD, BOOL, HWND# 音频检测
import time
from ctypes import POINTER, cast
from comtypes import CLSCTX_ALL
from pycaw.pycaw import AudioUtilities, IAudioMeterInformationnow_dir = os.path.abspath(os.path.dirname(__file__))
log_file_path = os.path.join(now_dir, "log.log")if os.path.exists(log_file_path):os.remove(log_file_path)
class LASTINPUTINFO(Str