我正在编写一个简单的python脚本,该脚本不断检查充电器是否连接到计算机,并在充电器从计算机上卸下时创建一个peep声音(有点防盗),如果使用nircmd命令禁用了系统音量,则启用系统音量。
我正在寻找一种将这些信息发送到PHP服务器并从那里在线阅读的方法。有谁能告诉我如何将输出从客户端发送到服务器端吗?提前非常感谢,这是密码
import os
import ctypes
import time
from ctypes import wintypes
import winsound
import socket
class SYSTEM_POWER_STATUS(ctypes.Structure):
_fields_ = [
('ACLineStatus', wintypes.BYTE),
('BatteryFlag', wintypes.BYTE),
('BatteryLifePercent', wintypes.BYTE),
('BatteryLifeTime', wintypes.DWORD),
('BatteryFullLifeTime', wintypes.DWORD),
]
print(socket.gethostname())
SYSTEM_POWER_STATUS_P = ctypes.POINTER(SYSTEM_POWER_STATUS)
GetSystemPowerStatus = ctypes.windll.kernel32.GetSystemPowerStatus
GetSystemPowerStatus.argtypes = [SYSTEM_POWER_STATUS_P]
GetSystemPowerStatus.restype = wintypes.BOOL
status = SYSTEM_POWER_STATUS()
while True:
if not GetSystemPowerStatus(ctypes.pointer(status)):
raise ctypes.WinError()
if(status.ACLineStatus==1):
print('Charger Connected: ', "YES")
elif(status.ACLineStatus==0):
print('Charger Connected: ', "NO")
winsound.Beep(2000,1000)
if(status.BatteryFlag==-128):
print('Battery removed: ', "Yes")
winsound.Beep(2000,1000)
time.sleep(1)
if(status.ACLineStatus==0):
cmd = 'nircmd.exe mutesysvolume 0 && nircmd.exe setsysvolume 65535'
os.system(cmd)