Last active
March 5, 2017 15:48
-
-
Save rigaspapas/5da713b4722be6728d89bdb7841c03be to your computer and use it in GitHub Desktop.
A Python script that reflect the screen's image to your Corsair RGB keyboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CUE SDK from: https://github.com/10se1ucgo/cue_sdk | |
from cue_sdk import * | |
# Pillow library: https://pillow.readthedocs.io/en/4.0.x/ | |
import ImageGrab | |
import os | |
import time | |
# Setup the keys matrix | |
keys = [['Escape', 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12'], | |
['GraveAccentAndTilde', '_1', '_2', '_3', '_4', '_5', '_6', '_7', '_8', '_9', '_0', 'MinusAndUnderscore', 'EqualsAndPlus', 'Backspace'], | |
['Tab', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'BracketLeft', 'BracketRight', 'Enter'], | |
['CapsLock', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'SemicolonAndColon', 'ApostropheAndDoubleQuote', 'NonUsTilde'], | |
['LeftShift', 'NonUsBackslash', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', 'CommaAndLessThan', 'PeriodAndBiggerThan', 'SlashAndQuestionMark', 'RightShift'], | |
['LeftCtrl', 'LeftGui', 'LeftAlt', 'Space','Space','Space','Space','Space', 'RightAlt', 'RightGui', 'Application', 'RightCtrl']] | |
os.chdir('{{PATH_TO_CUESDK_DLL}}') | |
Corsair = CUESDK("CUESDK_2015.dll") | |
if Corsair.RequestControl(CAM.ExclusiveLightingControl): | |
while True: | |
# Take a screenshot and create a thumbnail out from it | |
ss = ImageGrab.grab() | |
# My screen has 21:9 ratio, define the dimensions that match yours | |
ss.thumbnail((15, 6)) | |
# Set each key color according to the thumbnail | |
for y in xrange(0, len(keys)): | |
for x in xrange(0, len(keys[y])): | |
color = ss.getpixel((x, y)) | |
Corsair.set_led_colors(CorsairLedColor(getattr(CLK, keys[y][x]), color[0], color[1], color[2])) | |
# Remove for non-stop refresh | |
time.sleep(.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment