Skip to content

Instantly share code, notes, and snippets.

@Elektordi
Created September 27, 2023 22:56
Show Gist options
  • Save Elektordi/d4232e36911b60fb3351eda5d1a1b919 to your computer and use it in GitHub Desktop.
Save Elektordi/d4232e36911b60fb3351eda5d1a1b919 to your computer and use it in GitHub Desktop.
Slides remote passthrough
#!/usr/bin/env python3
import evdev
import xdo
dev = None
for d in [evdev.InputDevice(path) for path in evdev.list_devices()]:
# print(device.path, device.name, device.phys)
if d.name == "NORWII Norwii Wireless Presenter Keyboard":
dev = d
break
assert dev
dev.grab()
x = xdo.Xdo()
windows = x.search_windows(b".pptx ", only_visible=True, require=True)
print(windows)
assert windows
win = windows[0]
for event in dev.read_loop():
if event.type == evdev.ecodes.EV_KEY:
key = evdev.categorize(event)
print(key)
if key.keystate != evdev.KeyEvent.key_down:
continue
if key.scancode == evdev.ecodes.KEY_DOWN:
press = b"Down"
elif key.scancode == evdev.ecodes.KEY_UP:
press = b"Up"
else:
print("(Key not implemented)")
continue
x.send_keysequence_window(win, press)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment