Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8725773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:06:35+00:00 2026-06-13T08:06:35+00:00

I need to simulate some mouse events and keyboard events for my project and

  • 0

I need to simulate some mouse events and keyboard events for my project and having trouble finding much information about the same.

I tried out the original X11 code for simulating mouse which I got from the stackoverflow post, it seems to work fine but I’m not able to understand the code:

void mouseClick(int button)
{
   Display *display = XOpenDisplay(NULL);

   XEvent event;

   if(display == NULL)
   {
      fprintf(stderr, "Errore nell'apertura del Display !!!\n");
      exit(EXIT_FAILURE);
   }

   memset(&event, 0x00, sizeof(event));

   event.type = ButtonPress;
   event.xbutton.button = button;
   event.xbutton.same_screen = True;

   XQueryPointer(display, RootWindow(display, DefaultScreen(display)), &event.xbutton.root, &event.xbutton.window, &event.xbutton.x_root, &event.xbutton.y_root, &event.xbutton.x, &event.xbutton.y, &event.xbutton.state);

   event.xbutton.subwindow = event.xbutton.window;

   while(event.xbutton.subwindow)
   {
      event.xbutton.window = event.xbutton.subwindow;

      XQueryPointer(display, event.xbutton.window, &event.xbutton.root, &event.xbutton.subwindow, &event.xbutton.x_root, &event.xbutton.y_root, &event.xbutton.x, &event.xbutton.y, &event.xbutton.state);
   }

   if(XSendEvent(display, PointerWindow, True, 0xfff, &event) == 0) fprintf(stderr, "Error\n");

   XFlush(display);

   usleep(100000);

   event.type = ButtonRelease;
   event.xbutton.state = 0x100;

   if(XSendEvent(display, PointerWindow, True, 0xfff, &event) == 0) fprintf(stderr, "Error\n");

   XFlush(display);

   XCloseDisplay(display);
}

so I wanted to ask if there were any simpler abstractions over the xlib library without going through all these as i even need to simulate keyboard actions which could be used with g++.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:06:36+00:00Added an answer on June 13, 2026 at 8:06 am

    xdotool is a command line interface that I’ve used before and it’s available in the Fedora repos.

    There is also the related libxdo that seems like it would be a more direct aid. For example

    xdo_mousemove (const xdo_t * xdo, int x, int y, int screen)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing an app where I need to simulate key press events on a
I am working on a Java project and need to have a keypress simulate
and our client need we to simulate 50 person to work at the same
i need to make some kind of virtual keyboard, to send keyboard signals to
So I need to simulate a click on a specific position on some DisplayObject.
I'm having the following problem in python. I need to do some calculations in
I need to redirect an user, but I need to simulate some form processing,
I need some actionscript code to simulate the dragging and dropping of a Sprite,
I have started testing my UI using qUnit, so I need to simulate some
My app will need to simulate a key being held down during some time.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.