I was working on this simple python script that constantly checks if the charger is connected to the computer and creates a peep sound when the charger is removed from the computer (Sort of anti-theft) and enables system volume if it is disabled with nircmd command.
I was looking for a way of sending this information to PHP server and reading it from there online. Would anyone be able to tell me how to send the output from the client-side to the server-side? Thank you so much in advance and here is the code
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)