Find Qt Window_hWnd in third party software



  • Hi

    I need to find the handels in a third party. I use this to find other Languas handels but dont know Qt can any one help me just to get the child handels please
    "Test Application = the third party software
    ListOfChild(0) = the index
    Index=(0) up to the index max

    How can I find Qt child Handels

    @Q Dim Window_hWnd As IntPtr = FindWindow(Nothing, "Test Application") '<=Replace "Test Application"

    'Get the length of the text
    Dim MaxTextLength As Integer = SendMessageA(ListOfChild(0), WM_GETTEXTLENGTH, IntPtr.Zero, IntPtr.Zero) + 1

    'Create an unmanaged array
    Dim Pointer As IntPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(MaxTextLength)

    'Get the text in the unmanaged array
    Dim TextLength As Integer = SendMessageA(ListOfChild(0), WM_GETTEXT, CType(MaxTextLength, IntPtr), Pointer)@



  • You want to control a 3rd party Qt window from VB?

    That doesn't really have to do Qt itself, but a Qt window should not act differently then any other window (in most desktop's).

    You might get better answers at a VB forum.



  • have a look how Spy from MS works. Or look at Microsoft Accessibility support. Perhaps that helps you finding the windows...



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



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



  • *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



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



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



  • 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)@



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



  • 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).



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



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



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



  • 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



  • 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!



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



  • [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...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.