Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Send arrow keys via QProcess in any platform

    General and Desktop
    key arrowkeys qprocess linux windows 7
    5
    11
    5007
    Loading More Posts
    • 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.
    • K
      koahnig @Mark81 last edited by

      @Mark81

      Not sure what youare trying to do there, but why would it matter?
      Your process started with QProcess runs on the same platform as your application.

      Qt::Key_Left is a constant

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply Reply Quote 0
      • raven-worx
        raven-worx Moderators @Mark81 last edited by

        @Mark81
        there is no Qt-crossplatform way. You will have to specify the native implementation yourself. Also you need to figure out how to access the window handle of the newly created process. And then send the (native) key event/message to this window handle.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply Reply Quote 1
        • M
          Mark81 last edited by

          ehm... two opposite answers :o)

          Qt::Key_Left is a costant, true, but it doesn't hold the actual code for keys. I.e. under linux arrow left is \esc [ D.

          raven-worx 1 Reply Last reply Reply Quote 0
          • m.sue
            m.sue last edited by

            Hi,
            the question is: what do you want to achieve? Remotely controll another application i.e. let it make a "key left" movement without a user being in front of the keyboard that presses the relevant key?
            -Michael.

            M 1 Reply Last reply Reply Quote 0
            • raven-worx
              raven-worx Moderators @Mark81 last edited by

              @Mark81 said in Send arrow keys via QProcess in any platform:

              ehm... two opposite answers :o)
              Qt::Key_Left is a costant, true, but it doesn't hold the actual code for keys. I.e. under linux arrow left is \esc [ D.

              The Qt::Key_* constants are just used inside the Qt framework. The are mapped when the native key event is received. And from there on only the enum constants are used for convenience/cross-platform reasons of course.

              So such a feature you want to achieve goes way beyond a framework such as Qt and requires you to do the hard work yourself.

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply Reply Quote 1
              • M
                Mark81 @m.sue last edited by

                @m.sue said in Send arrow keys via QProcess in any platform:

                the question is: what do you want to achieve? Remotely controll another application i.e. let it make a "key left" movement without a user being in front of the keyboard that presses the relevant key?

                Exactly.

                VRonin 1 Reply Last reply Reply Quote 0
                • VRonin
                  VRonin @Mark81 last edited by

                  @Mark81 Then do you really need Qt? there are already mature tools to do those kind of things, for windows: http://ahkscript.org/ and for linux: http://www.semicomplete.com/projects/xdotool/

                  "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                  ~Napoleon Bonaparte

                  On a crusade to banish setIndexWidget() from the holy land of Qt

                  M 1 Reply Last reply Reply Quote 2
                  • m.sue
                    m.sue last edited by

                    @Mark81: You could also use the QTest module. There is a function keypress there that does the trick: http://doc.qt.io/qt-5/qtest.html. This function even expects a platform independent Qt::Key parameter.
                    You would have to establish the communication (protocol) by yourself, though.
                    -Michael.

                    raven-worx 1 Reply Last reply Reply Quote 1
                    • raven-worx
                      raven-worx Moderators @m.sue last edited by

                      @m.sue
                      well the problem isn't to send a KeyEvent inside your application, but to send a native keyevent from one process to separate process (not even necessarily Qt)

                      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                      If you have a question please use the forum so others can benefit from the solution in the future

                      1 Reply Last reply Reply Quote 0
                      • M
                        Mark81 @VRonin last edited by Mark81

                        @VRonin said in Send arrow keys via QProcess in any platform:

                        @Mark81 Then do you really need Qt? there are already mature tools to do those kind of things, for windows: http://ahkscript.org/ and for linux: http://www.semicomplete.com/projects/xdotool/

                        I don't need Qt for this. But I have a quite large application that does a lot of things. One of those, is to launch external applications and send them keystrokes as you would type in front of a keyboard.

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post