Results 1 to 5 of 5

Thread: How to track mouse position and change it in linux

  1. #1
    Join Date
    Mar 2019
    Beans
    2

    How to track mouse position and change it in linux

    In windows I can use <windows.h> and

    POINT p;
    while (1) {
    GetCursorPos(&p);
    SetCursorPos(p.x + 3, p.y);

    to get the position and change it.

    How do I do the same in Linux? Thanks.

  2. #2
    Join Date
    Feb 2008
    Location
    Texas
    Beans
    29,807
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: How to track mouse position and change it in linux

    Thread moved to New to Ubuntu a more appropriate sub-forum.

  3. #3
    Join Date
    Mar 2019
    Beans
    2

    Re: How to track mouse position and change it in linux

    I found some said reading and writing in the file /dev/input/mice.
    It does not work on my computer, though. The system is Ubuntu 18.04.2 LTS

  4. #4
    Join Date
    Aug 2011
    Location
    52.5° N 6.4° E
    Beans
    6,820
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: How to track mouse position and change it in linux

    When I program I mostly make command line tools, or sometimes tools with command line input but graphical output, but I've made a few programs that use the mouse. I think it's best to use some API that can tell you the mouse position and that's somewhat portable at the same time. Last time I used GLFW. If you install it along with the documentation, the manual should be on your system.

    /dev/input/mice shouldn't work, as applications should only know about mouse events in their own window. It only has read and write access for root and the input group.

  5. #5
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: How to track mouse position and change it in linux

    I've always used testing programs that send x-events - usually there isn't any need to move the mouse since we can just send the button-click event to the button directly. There are keyboard and mouse recording tools which can be played back. I've been out of this field long enough that I don't recall any names anymore. We used commercial tools which weren't too cheap.

    Google found these: https://nnc3.com/mags/LM10/Magazine/...e/article.html says something about xnee, gnee, and cnee.
    gnee and cnee are in the 16.04 repos.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •