I'm now changing keyboard colours with python!
You'll need python 2.7, pywin32 and WMI
import wmi
c = wmi.WMI(namespace="root\WMI")
clevo = "select * from CLEVO_GET"
myhex = "00FF00";
left_color = int("F0"+myhex, 16)
mid_color = int("F1"+myhex, 16)
right_color = int("F2"+myhex, 16)
for doy in c.query(clevo):
#print color
doy.SetKBLED(right_color)
I can also create sockets and capture the udp packets from MiLight Controller:
Download:
epocapp.bitbucket.org/milight/
Set Number of Colours - 4 Colors (2 Controllers)
Then Options > Settings
Create 4 local i.p addresses, (all 127.0.0.1) with port numbers 5005,5006,5007,5008
Colours.py
import socket
import binascii
import wmi
import struct
c = wmi.WMI(namespace="root\WMI")
clevo = "select * from CLEVO_GET"
UDP_IP = "127.0.0.1"
UDP_PORT = 5005
UDP_PORT2 = 5006
UDP_PORT3 = 5007
UDP_PORT4 = 5008
sock = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP
sock.bind((UDP_IP, UDP_PORT))
sock2 = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP
sock2.bind((UDP_IP, UDP_PORT2))
sock3 = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP
sock3.bind((UDP_IP, UDP_PORT3))
sock4 = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP
sock4.bind((UDP_IP, UDP_PORT4))
while True:
data, addr = sock.recvfrom(1024)
data2, addr2 = sock2.recvfrom(1024)
data3, addr3 = sock3.recvfrom(1024)
data4, addr3 = sock4.recvfrom(1024)
ark = int("F0"+binascii.hexlify(data),16)
ark2 = int("F1"+binascii.hexlify(data2),16)
ark3 = int("F1"+binascii.hexlify(data3),16)
ark4 = int("F2"+binascii.hexlify(data4),16)
for doy in c.query(clevo):
doy.SetKBLED(ark)
doy.SetKBLED(ark2)
doy.SetKBLED(ark4)
print "packet",data,"| hex",ark
Your keyboard should be changing colours!
This is where I'm currently stuck.
In the terminal, the data you will see is udp packets converted straight to hex but I'm unsure this is correct..
..you can see the packets are 3 characters long and I have no idea what the encoding is, so we won't get the proper hex values until this is fixed. Could anyone shed any light on this?