0

I have a Windows application which I want to port it to Linux. In this application, I send mouse click events to other applications. The function which does the job is like this:

void MainWindow::send_mouse_event(HWND hwnd, int x, int y)
{
    int coordinate = x | (y << 16);
    LRESULT res = SendMessage(hwnd, WM_LBUTTONDOWN, 0x00000001, coordinate);
    SendMessage(hwnd, WM_LBUTTONUP, 0x00000000, coordinate);
}

I searched for equivalent code in Linux and I found xdotool. As far as I understood, using xdotool, you have to move the mouse to a point at first, and then click that point. But in Windows, I could send mouse click events virtually to other windows without moving the mouse. So is the story true about Linux? Is it possible to send a click event to other applications without (really) moving the mouse in Linux? I'm using Ubuntu 18.04.

s4eed
  • 7,173
  • 9
  • 67
  • 104
  • A related question already posted in SO : https://stackoverflow.com/questions/20595716/control-mouse-by-writing-to-dev-input-mice – tunglt Nov 25 '18 at 21:58
  • 1
    While you're at it, consider fixing the Windows version, too: [You can’t simulate keyboard input with PostMessage](https://blogs.msdn.microsoft.com/oldnewthing/20050530-11/?p=35513). The same underlying principles apply to mouse input. – IInspectable Nov 26 '18 at 00:12
  • @IInspectable But it's working :D anyway, thank you, I'll fix it. – s4eed Nov 26 '18 at 12:46

0 Answers0