Send mouse click to OS's window manager
-
I need to simulate a mouse click, and it needs to reach the windows on my desktop, not part of my QT application. I have tried posting a mouseEvent to QApplication::desktop(), but to no avail. Posts on the net suggest that the only way to do this is to write OS-specific code. Comments/suggestions? Thank you.
-
Hi,
That's correct. There's no reason for an application to be able to send arbitrarily clicks or other events to other random applications.
-
you are controlling the gui at the xlib library level, not Qt. Yes, it is possible, but that discussion is way outside the scope of this forum, and there are examples online. Did you google "manual insertion of X11 events"?
-
you are controlling the gui at the xlib library level, not Qt. Yes, it is possible, but that discussion is way outside the scope of this forum, and there are examples online. Did you google "manual insertion of X11 events"?
@Kent-Dorfman I did find a code sample that works for me on linux: [https://www.linuxquestions.org/questions/programming-9/simulating-a-mouse-click-594576/](link url) . On Windows, the corresponding functionality is with SendInput, with which I am having trouble. But, as you have pointed out, I will raise this at a different forum. Thank you for your time.
-
@Kent-Dorfman I did find a code sample that works for me on linux: [https://www.linuxquestions.org/questions/programming-9/simulating-a-mouse-click-594576/](link url) . On Windows, the corresponding functionality is with SendInput, with which I am having trouble. But, as you have pointed out, I will raise this at a different forum. Thank you for your time.
@normvcr
Under Windows I would saySendInput
is indeed the way to go. "with which I am having trouble": be aware of https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendinput:This function is subject to UIPI. Applications are permitted to inject input only into applications that are at an equal or lesser integrity level.