Skip to content

Instantly share code, notes, and snippets.

@Akkiesoft
Created December 25, 2023 14:46
Show Gist options
  • Save Akkiesoft/f85e60288644d4e9bf2b7dafcc0764ee to your computer and use it in GitHub Desktop.
Save Akkiesoft/f85e60288644d4e9bf2b7dafcc0764ee to your computer and use it in GitHub Desktop.
マイクラで頭上のブロックをぶち抜いて後ろに下がるマクロ。GP2をショートさせて使う。CircuitPython用
# Written in CircuitPython
# for Raspberry Pi Pico
import board
import digitalio
from time import sleep
import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode
from adafruit_hid.mouse import Mouse
mouse = Mouse(usb_hid.devices)
keyboard=Keyboard(usb_hid.devices)
button = digitalio.DigitalInOut(board.GP2)
button.switch_to_input(pull=digitalio.Pull.UP)
led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT
i = 0
while True:
if not button.value:
mouse.press(Mouse.LEFT_BUTTON)
led.value = i
keyboard.press(Keycode.S)
sleep(0.24)
keyboard.release(Keycode.S)
sleep(3)
i = 1 - i
else:
mouse.release(Mouse.LEFT_BUTTON)
keyboard.release(Keycode.S)
led.value = 0
i = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment