Skip to content

Instantly share code, notes, and snippets.

@Nuigurumi777
Nuigurumi777 / autolayer.py
Last active February 15, 2024 03:16
An example of sending layer changing commands from Windows host to Moonlander keyboard
import ctypes
import hid, sys
import time
user32 = ctypes.windll.user32
def get_active_language():
h_wnd = user32.GetForegroundWindow()
thread_id = user32.GetWindowThreadProcessId(h_wnd, 0)
klid = user32.GetKeyboardLayout(thread_id)