Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. Find Qt Window_hWnd in third party software

Find Qt Window_hWnd in third party software

Scheduled Pinned Locked Moved Language Bindings
18 Posts 5 Posters 11.3k 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.
  • B Offline
    B Offline
    Buyer_SA
    wrote on last edited by
    #4

    I don’t really want to control it I just need to find the Window_hWnd to read the Text.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #5

      You can use MSAA for finding it. You can also call EnumerateXXX to enumerate all top level windows, but that gets more complicated.
      Additionaklly, if the 3rd party is a Qt app, it depends, whether it uses real windows or not. Qt can also only have one HWND (for the main window) and the rest being handled internally by Qt. with MSAA build in,m you can acces sthem. And how to you want to get text out? and out of what?

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Buyer_SA
        wrote on last edited by
        #6

        *This do get the Top Window_hWnd *

        Dim Window_hWnd As IntPtr = FindWindow(Nothing, “Test Application”) ’<=Replace “Test Application”

        But the ListOfChild(0), Index is 0 - there is no Child but I know there is. I want to read the text from the chat window that is part of the Top Window_hWnd

        But I dont know how to search for the child windows
        Top Window_hWnd = Class = QWidget

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #7

          If the top window is a AWidget and it uses the default since QT 4.4 (i think it's default), there are no real child windows. And you can't read thje text out with default windows Events. Qt does not use MS Window types for edit fields etc, they are all build in Qt as they must be identical throuout the different platforms...
          So I think, the only option would be MSAA...
          If the app added MSAA support....

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • ? This user is from outside of this forum
            ? This user is from outside of this forum
            Guest
            wrote on last edited by
            #8

            hi Buyer_SA, can you pls enclose your code with the @ tag ... easier to read

            1 Reply Last reply
            0
            • B Offline
              B Offline
              Buyer_SA
              wrote on last edited by
              #9

              This is not the full code and will not do anything in this state If you need more of the code ask

              What is MSAA

              @Dim Window_hWnd As IntPtr = FindWindow(Nothing, “Test Application”) ’<=Replace “Test Application”
              Dim MaxTextLength As Integer = SendMessageA(ListOfChild(0), WM_GETTEXTLENGTH, IntPtr.Zero, IntPtr.Zero) + 1
              Dim Pointer As IntPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(MaxTextLength)
              Dim TextLength As Integer = SendMessageA(ListOfChild(0), WM_GETTEXT, CType(MaxTextLength, IntPtr), Pointer)@

              1 Reply Last reply
              0
              • B Offline
                B Offline
                Buyer_SA
                wrote on last edited by
                #10

                How will you go about it to get the text from Widget

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  giesbert
                  wrote on last edited by
                  #11

                  MSAA = Microsoft Accessibility Support
                  A posibility to auery windows including their states and children. Qt has support for that, if the app added it. I see no other chance to get text out of a QWidget from outside the process. Default windows API calls will not work (as GetWindowText).

                  Nokia Certified Qt Specialist.
                  Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    Buyer_SA
                    wrote on last edited by
                    #12

                    What about something like this

                    @Dim widget As Pointer(Of QWidget) = QWidget.find(DirectCast(hwnd, WId))
                    Dim listview As Pointer(Of QListView) = DirectCast(widget, QListView)
                    Dim model As QAbstractItemModel = listview.model()@

                    Or

                    using QObject::children() which returns, a list of all the children of any QObject.

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      giesbert
                      wrote on last edited by
                      #13

                      As you are in VB, you have no access to Qt Code (thats C++).
                      Or what are you trying to do?

                      Nokia Certified Qt Specialist.
                      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                      1 Reply Last reply
                      0
                      • B Offline
                        B Offline
                        Buyer_SA
                        wrote on last edited by
                        #14

                        Do you have C++ code that can get Qt text for third party Software.

                        1 Reply Last reply
                        0
                        • G Offline
                          G Offline
                          giesbert
                          wrote on last edited by
                          #15

                          You have no chance to get the text out of third party. Only if it supoports MSAA (Microsoft Active Accessibility). That's what I told you some posts up. But as you suggested to use Pointer(Of QWidget) = QWidget.find(DirectCast(hwnd..., I said that those classes are only for C++.
                          But from outside of the process, it's getting difficult. For "normal" Win32 windows classes there are possibilities, but QWidgets do not depend on "normal" Win32 window types.

                          So, again: try out using MSAA (search "http://msdn.microsoft.com":http://msdn.microsoft.com for it).

                          For examples on how to program that, you can also look at: "http://www.codeproject.com/KB/winsdk/MSAA_UI_Automation.aspx":http://www.codeproject.com/KB/winsdk/MSAA_UI_Automation.aspx

                          Nokia Certified Qt Specialist.
                          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                          1 Reply Last reply
                          0
                          • P Offline
                            P Offline
                            pmcfrack
                            wrote on last edited by
                            #16

                            I know this is a rather old post, however, this is the exact problem I am trying to work around. Here is a link to my question: http://developer.qt.nokia.com/forums/viewthread/4402/#26159

                            Does anyone have a work around for this?

                            Thanks!

                            1 Reply Last reply
                            0
                            • G Offline
                              G Offline
                              giesbert
                              wrote on last edited by
                              #17

                              What does getting data from widgets have to do with getting window handles?

                              Nokia Certified Qt Specialist.
                              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                              1 Reply Last reply
                              0
                              • A Offline
                                A Offline
                                andre
                                wrote on last edited by
                                #18

                                [quote author="pmcfrack" date="1300306178"]I know this is a rather old post, however, this is the exact problem I am trying to work around. Here is a link to my question: http://developer.qt.nokia.com/forums/viewthread/4402/#26159

                                Does anyone have a work around for this?

                                Thanks![/quote]

                                Perhaps you should start responding in that thread then again? It is not like you did not get any reactions there...

                                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