Sending mouse click events to other windows in Linux without moving the mouse

3k Views Asked by At

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.

0

There are 0 best solutions below