Skip to content

Instantly share code, notes, and snippets.

@FoamyGuy
Last active April 18, 2020 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FoamyGuy/36b0873acee2420ba314a04f9a4f3d40 to your computer and use it in GitHub Desktop.
Save FoamyGuy/36b0873acee2420ba314a04f9a4f3d40 to your computer and use it in GitHub Desktop.
from adafruit_hid.mouse import Mouse
import time
import board
import touchio
import usb_hid
mouse = Mouse(usb_hid.devices)
touch_pad = board.A0
touch = touchio.TouchIn(touch_pad)
prev_value = False
while True:
cur_value = touch.value
if cur_value and not prev_value:
print("Touched!")
# smash the mouse all the way to the top left
mouse.move(x=-2000, y=-2000)
# move to desired location
mouse.move(x=160, y=210)
# send click
mouse.click(Mouse.LEFT_BUTTON)
prev_value = cur_value
time.sleep(0.05)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment