Search code examples
pythonpi

mouse.move tag not working for my autoclicker


i am currently making an autoclicker script for an samsung galaxy A70 with my raspberry pi pico in micro-python.

This is my code:
import time
import usb_hid
from adafruit_hid.mouse import Mouse
import board
import digitalio

mouse = Mouse(usb_hid.devices)
led = digitalio.DigitalInOut(board.GP25)
led.direction = digitalio.Direction.OUTPUT

led.value = False
time.sleep(25)
mouse.move(y=360)

while True:
        led.value = True
        mouse.click(mouse.LEFT_BUTTON)
        time.sleep(0.01)

The problem i currently have is that the mouse.move tag wont work, it keeps putting the cursor in the middle-bottom of my phone. i already tried using different values for the y coordinate but that doesnt seem to help it. does anyone have any idea how to fix this?


Solution

  • in adafruit_hid.mouse you have to Send USB HID reports before you use the LEFT_BUTTON so you have to put a variable at the start of your code like this

    LEFT_BUTTON = 1 for the LEFT MOUSE BUTTON

    RIGHT_BUTTON = 2 for the RIGHT MOUSE BUTTON

    MIDDLE_BUTTON = 4 for the MIDDLE MOUSE BUTTON

    so your code will be like this:

    import time
    import usb_hid
    from adafruit_hid.mouse import Mouse
    import board
    import digitalio
    
    MIDDLE_BUTTON = 4
    RIGHT_BUTTON = 2
    LEFT_BUTTON = 1
    
    mouse = Mouse(usb_hid.devices)
    led = digitalio.DigitalInOut(board.GP25)
    led.direction = digitalio.Direction.OUTPUT
    
    led.value = False
    time.sleep(25)
    mouse.move(y=360)
    
    while True:
            led.value = True
            mouse.click(mouse.LEFT_BUTTON)
            time.sleep(0.01)