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. How to force an event in external application? (controlling)
Forum Update on Monday, May 27th 2025

How to force an event in external application? (controlling)

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 1.8k Views
  • 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.
  • Arty.McLabinA Offline
    Arty.McLabinA Offline
    Arty.McLabin
    wrote on last edited by
    #1

    Hi, i'm curious about the ability to control external software, i've already used QProcess with console applications, providing std input to the "controlled" process, but how do i deal with any other kind of programs? for example, is there a way to send "escape key pressed" event to some pre-menu annoying video in a PC game to skip it? if it is not possible in Qt libs, are there any other tools to achieve that with the lovely Qt framework? thanks in advance!

    Static linking is cool. Really.

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

      If on windows platform.
      I would use Autoit3
      https://www.autoitscript.com/site/autoit/
      It has all you need for such things.

      Often such controlling will require a platform specific solution.
      for windows, it would be something like:

      HWND notepad = FindWindow(_T("Notepad"), NULL);
      HWND edit = FindWindowEx(notepad, NULL, _T("Edit"), NULL);
      SendMessage(edit, WM_SETTEXT, NULL, (LPARAM)_T("hello"));

      Arty.McLabinA 1 Reply Last reply
      0
      • mrjjM mrjj

        If on windows platform.
        I would use Autoit3
        https://www.autoitscript.com/site/autoit/
        It has all you need for such things.

        Often such controlling will require a platform specific solution.
        for windows, it would be something like:

        HWND notepad = FindWindow(_T("Notepad"), NULL);
        HWND edit = FindWindowEx(notepad, NULL, _T("Edit"), NULL);
        SendMessage(edit, WM_SETTEXT, NULL, (LPARAM)_T("hello"));

        Arty.McLabinA Offline
        Arty.McLabinA Offline
        Arty.McLabin
        wrote on last edited by
        #3

        @mrjj thanks, but i need a C++ solution for it..
        there must be something

        Static linking is cool. Really.

        mrjjM 1 Reply Last reply
        0
        • Arty.McLabinA Arty.McLabin

          @mrjj thanks, but i need a C++ solution for it..
          there must be something

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

          @Arty.McLabin
          Ok no autoit3 then :)

          well read
          http://www.codeproject.com/Articles/6819/SendKeys-in-C

          If you mean , you want a pure qt platform neutral solution, I have no idea. sorry.

          1 Reply Last reply
          1
          • Chris KawaC Online
            Chris KawaC Online
            Chris Kawa
            Lifetime Qt Champion
            wrote on last edited by Chris Kawa
            #5

            Unless the app has some mechanism built in to be interacted with (like standard in/out, app switches or some interface like dbus or rpc) there is no cross-platform way to do it.
            Even on a specific platform there might not be, depending on multitude of factors.

            On Windows you might try to sniff controls handles with something like spy++ (bundled with Visual Studio) and send OS messages (WM_XXX) to them, but that's hacky at best and will not work for example with Qt apps which mostly bypass native rendering and windowing.With Qt apps you might try to tinker with the app like Froglogic Squish tools do to get to know QObject structure of the app, but that's again very limited as you need to know the exact version of Qt used.

            In general this is a very bad bad idea. If an app doesn't provide you with a documented API to do it then it most likely doesn't want/can't handle such tinkering and you should not do it. It's basically reverse engineering and relying on undocumented behavior and anything you come up with will most likely break the minute the next version of the app comes out.

            Oh, and I'm not mentioning the legal aspect of such stuff, as you're probably aware that a lot of licences forbid this kind of outside modifications of running apps.

            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