import win32com.client
import time
import serial

ser = serial.Serial('COM23', 9600) # Define the port and the speed

def is_lol_running():
    wmi = win32com.client.GetObject("winmgmts:")
    processes = wmi.InstancesOf("Win32_Process")
    for process in processes:
        if process.Name == "League of Legends.exe":
            return True
    return False


while True:

    if is_lol_running():
        # print("LoL is running.")
        ser.write(b'1')
    else:
        # print("LoL is not running.")
        ser.write(b'0')
        
    time.sleep(1) # Wait 1 seconde before update
