Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Click and hold LMB

Click and hold LMB

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt creatorqt5
22 Posts 5 Posters 2.6k Views 4 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #11

    Hi
    You have to use native API
    https://stackoverflow.com/questions/7492529/how-to-simulate-a-mouse-movement

    I would check first with autoit3
    https://www.autoitscript.com/site/
    if it cant click on your game, you wont be able too either.

    1 Reply Last reply
    2
    • Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #12

      I've never heard that AI or bots in games need to take control of keyboard or mouse... In most cases, you can bypass it and make direct inputs...
      What should your 5s-click trigger? What do you want to achieve?

      EDIT:

      Is it for a bot in your game or 3rd party software and you want to write a bot in Qt? (my suggestion above only works, if you have full access to the code, which isn't the case when you are not using your own game...)


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      R 1 Reply Last reply
      0
      • Pl45m4P Pl45m4

        I've never heard that AI or bots in games need to take control of keyboard or mouse... In most cases, you can bypass it and make direct inputs...
        What should your 5s-click trigger? What do you want to achieve?

        EDIT:

        Is it for a bot in your game or 3rd party software and you want to write a bot in Qt? (my suggestion above only works, if you have full access to the code, which isn't the case when you are not using your own game...)

        R Offline
        R Offline
        rktech
        wrote on last edited by
        #13

        @Pl45m4 said in Click and hold LMB:

        I've never heard that AI or bots in games need to take control of keyboard or mouse... In most cases, you can bypass it and make direct inputs...
        What should your 5s-click trigger? What do you want to achieve?

        EDIT:

        Is it for a bot in your game or 3rd party software and you want to write a bot in Qt? (my suggestion above only works, if you have full access to the code, which isn't the case when you are not using your own game...)

        Of course it's not my own game.

        fcarneyF 1 Reply Last reply
        0
        • R rktech

          @Pl45m4 said in Click and hold LMB:

          I've never heard that AI or bots in games need to take control of keyboard or mouse... In most cases, you can bypass it and make direct inputs...
          What should your 5s-click trigger? What do you want to achieve?

          EDIT:

          Is it for a bot in your game or 3rd party software and you want to write a bot in Qt? (my suggestion above only works, if you have full access to the code, which isn't the case when you are not using your own game...)

          Of course it's not my own game.

          fcarneyF Offline
          fcarneyF Offline
          fcarney
          wrote on last edited by
          #14

          @rktech Where does the requirement that it must be C++ and Qt come from?

          C++ is a perfectly valid school of magic.

          R 1 Reply Last reply
          0
          • mrjjM mrjj

            @rktech
            So you try to do that to OTHER application correct ?

            so while you can do that internal in Qt app like

             QMouseEvent *mEvnPress = new QMouseEvent(QEvent::MouseButtonPress, QPoint(10, 10), Qt::LeftButton,
                                                         Qt::LeftButton, Qt::NoModifier);
                QMouseEvent *mEvnRelease = new QMouseEvent(QEvent::MouseButtonRelease, QPoint(10, 10),
                                                           Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
                QCoreApplication::sendEvent(pWidget, mEvnPress);
            
                QTimer::singleShot( 5000, [pWidget, mEvnRelease]() {
                    QCoreApplication::sendEvent(pWidget, mEvnRelease);
                });
            

            It wont work for outside.

            You must use native OS calls to do that.

            Is this on windows only ?
            or you need to work on linux / macos too ?

            R Offline
            R Offline
            rktech
            wrote on last edited by
            #15

            @mrjj said in Click and hold LMB:

            @rktech
            So you try to do that to OTHER application correct ?

            so while you can do that internal in Qt app like

             QMouseEvent *mEvnPress = new QMouseEvent(QEvent::MouseButtonPress, QPoint(10, 10), Qt::LeftButton,
                                                         Qt::LeftButton, Qt::NoModifier);
                QMouseEvent *mEvnRelease = new QMouseEvent(QEvent::MouseButtonRelease, QPoint(10, 10),
                                                           Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
                QCoreApplication::sendEvent(pWidget, mEvnPress);
            
                QTimer::singleShot( 5000, [pWidget, mEvnRelease]() {
                    QCoreApplication::sendEvent(pWidget, mEvnRelease);
                });
            

            It wont work for outside.

            You must use native OS calls to do that.

            Is this on windows only ?
            or you need to work on linux / macos too ?

            use of undeclared identifier 'pWidget'

            mrjjM 1 Reply Last reply
            0
            • fcarneyF fcarney

              @rktech Where does the requirement that it must be C++ and Qt come from?

              R Offline
              R Offline
              rktech
              wrote on last edited by
              #16

              @fcarney It is not a requirement, but I want some high-level language.

              fcarneyF 1 Reply Last reply
              0
              • R rktech

                @fcarney It is not a requirement, but I want some high-level language.

                fcarneyF Offline
                fcarneyF Offline
                fcarney
                wrote on last edited by
                #17

                @rktech said in Click and hold LMB:

                It is not a requirement, but I want some high-level language.

                I have used that python library I pointed to you. I have automated games at home and applications at work with that library. It has functions to find the process, interface to widgets if available, it also has raw clicks based upon position. It already has all the function calls figured out for the windows platform. It is also extremely easy to use compared to a C++ solution. You most likely will not find a widget set in a game. Since they are rendering to opengl or directx. So raw clicks is your best bet.

                If you pursue a C++ solution you will have to either find an automation library or dig through the windows api to find the calls to do click events or key events.

                You could create a python based qt application and use that automation library for the backend portion of the app.

                C++ is a perfectly valid school of magic.

                R 1 Reply Last reply
                0
                • fcarneyF fcarney

                  @rktech said in Click and hold LMB:

                  It is not a requirement, but I want some high-level language.

                  I have used that python library I pointed to you. I have automated games at home and applications at work with that library. It has functions to find the process, interface to widgets if available, it also has raw clicks based upon position. It already has all the function calls figured out for the windows platform. It is also extremely easy to use compared to a C++ solution. You most likely will not find a widget set in a game. Since they are rendering to opengl or directx. So raw clicks is your best bet.

                  If you pursue a C++ solution you will have to either find an automation library or dig through the windows api to find the calls to do click events or key events.

                  You could create a python based qt application and use that automation library for the backend portion of the app.

                  R Offline
                  R Offline
                  rktech
                  wrote on last edited by
                  #18

                  @fcarney The problem is, that I don't know Python.

                  SGaistS 1 Reply Last reply
                  0
                  • R rktech

                    @fcarney The problem is, that I don't know Python.

                    SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #19

                    @rktech said in Click and hold LMB:

                    @fcarney The problem is, that I don't know Python.

                    It's maybe a good time to learn :-)

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

                    R 1 Reply Last reply
                    1
                    • SGaistS SGaist

                      @rktech said in Click and hold LMB:

                      @fcarney The problem is, that I don't know Python.

                      It's maybe a good time to learn :-)

                      R Offline
                      R Offline
                      rktech
                      wrote on last edited by
                      #20

                      @SGaist said in Click and hold LMB:

                      It's maybe a good time to learn :-)

                      I don't like the syntax, that's the problem.

                      mrjjM 1 Reply Last reply
                      0
                      • R rktech

                        @mrjj said in Click and hold LMB:

                        @rktech
                        So you try to do that to OTHER application correct ?

                        so while you can do that internal in Qt app like

                         QMouseEvent *mEvnPress = new QMouseEvent(QEvent::MouseButtonPress, QPoint(10, 10), Qt::LeftButton,
                                                                     Qt::LeftButton, Qt::NoModifier);
                            QMouseEvent *mEvnRelease = new QMouseEvent(QEvent::MouseButtonRelease, QPoint(10, 10),
                                                                       Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
                            QCoreApplication::sendEvent(pWidget, mEvnPress);
                        
                            QTimer::singleShot( 5000, [pWidget, mEvnRelease]() {
                                QCoreApplication::sendEvent(pWidget, mEvnRelease);
                            });
                        

                        It wont work for outside.

                        You must use native OS calls to do that.

                        Is this on windows only ?
                        or you need to work on linux / macos too ?

                        use of undeclared identifier 'pWidget'

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #21

                        @rktech
                        hi
                        pWidget is the widget you want to "hold"
                        but its for inside Qt app so i guess its uninteresting.

                        1 Reply Last reply
                        1
                        • R rktech

                          @SGaist said in Click and hold LMB:

                          It's maybe a good time to learn :-)

                          I don't like the syntax, that's the problem.

                          mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by
                          #22

                          @rktech

                          • I don't like the syntax, that's the problem.

                          Well I don't like python syntax either but it really beats hands down the
                          syntax you will be looking at using native API to send external events to the game app.

                          So if provides the features you want to bot the app,
                          it might end up be less ugly code in python than using c++ and windows api :)

                          1 Reply Last reply
                          1

                          • Login

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