Skip to content

how to make ABS_X and ABS_Y attributes work with mouse pointer movement #43

Description

@VictorGimenez

I would like to make the mouse pointer/cursor move independently and directly to the given x and y positions without the need to use the relative attributes (REL_X, REL_Y) seen that these two ones make the mouse movement using as reference the actual x and y positions. I wrote this script below to try make the mouse pointer goes directly but nothing happens.

import uinput
from time import sleep


def createDevice():
    device = uinput.Device([
        uinput.ABS_X,
        uinput.ABS_Y,
        uinput.BTN_LEFT,
        uinput.BTN_RIGHT,
        ])
    return device

def emitActions(device):
    sleep(1)
    device.emit(uinput.ABS_X, 26, syn=False)
    sleep(1)
    device.emit(uinput.ABS_Y, 665, syn=False)
    sleep(1)
    device.syn()
    sleep(1)
    device.emit(uinput.BTN_LEFT, 1)
    sleep(1)
    device.emit(uinput.BTN_LEFT, 0)

def main():
    dev = createDevice()
    emitActions(dev)

if __name__ == "__main__":
    main()

When I debugged this code I didn't get errors, but I would like to know what's missing there in this code to make that the mouse pointer goes to the desired x and y positions?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions