Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Send mouse click to OS's window manager
Forum Updated to NodeBB v4.3 + New Features

Send mouse click to OS's window manager

Scheduled Pinned Locked Moved Unsolved C++ Gurus
6 Posts 4 Posters 1.6k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    normvcr
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • N Offline
        N Offline
        normvcr
        wrote on last edited by
        #3

        Thank you for confirming what I had gleaned from the net. I can assure you, though, that I have good reasons for what I wish to accomplish :-) .

        1 Reply Last reply
        0
        • Kent-DorfmanK Offline
          Kent-DorfmanK Offline
          Kent-Dorfman
          wrote on last edited by
          #4

          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"?

          N 1 Reply Last reply
          1
          • Kent-DorfmanK Kent-Dorfman

            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"?

            N Offline
            N Offline
            normvcr
            wrote on last edited by
            #5

            @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.

            JonBJ 1 Reply Last reply
            2
            • N normvcr

              @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.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6

              @normvcr
              Under Windows I would say SendInput 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.

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved