Jump to content

Window Info Control:Name in C++ Win32


Recommended Posts

Hello everyone,

When I’m using “AutoIt v3 Window Info” with C# application in control, I can get the name of the control I want to interact with.

But when I’m “spying” a Cpp Win32 application, the field is always blank. Is there a way to get information in this field?

Do you know a way to identify individually each component of a Cpp Win32 App? Even by adding code into the application itself.

Thanks for your help.

Link to comment
Share on other sites

Looking at the _WinAPI_GetWindowLong($hWnd, $iIndex) UDF there's an Index called $GWL_USERDATA...

Though the MSDN article for SetWindowLong says "This data is intended for use by the application that created the window.", maybe theres a way to fill that info with a custom index and use it in AutoIt?

Edit: Nope, after some testing it does not seem to be accessible :blink:.

Edit #2: "Sets the 32-bit value associated with the window"... encode your values or just make up an index of yourself.

Compile and run TargetGUI.au3, then run Check.au3 to read the $GWL_USERDATA from the TargetGUI.au3.

TargetGUI.au3

#include <winapi.au3>
#include <GUIConstantsEx.au3>
#include <Constants.au3>

GUICreate("Test-My-GUI")
$c_Button = GUICtrlCreateButton("Test", 10, 10, 200)

ConsoleWrite(_WinAPI_SetWindowLong(GUICtrlGetHandle($c_Button), $GWL_USERDATA, 6) & @crlf)

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $c_Button
            MsgBox(0, "", _WinAPI_GetWindowLong(GUICtrlGetHandle($c_Button), $GWL_USERDATA))
    EndSwitch

WEnd
GUIDelete()

Check.au3

#include <_EnumChildWindows.au3>
#include <array.au3>
#include <constants.au3>

$hWnd = WinGetHandle("Test-My-GUI", "")

$aEnumList = _EnumChildWindows($hWnd)

_ArrayDisplay($aEnumList)

For $i = 1 To UBound($aEnumList) - 1
    MsgBox(0, "", $aEnumList[$i][0] & @crlf & _WinAPI_GetWindowLong($aEnumList[$i][0], $GWL_USERDATA))
Next

_EnumChildWindows

Edited by KaFu
Link to comment
Share on other sites

  • 3 weeks later...

Sorry the delay.

EDIT :

Ok my bad I wasn't setting the button correctly

I've got the get the handle first then set it.

SetWindowLongPtr(Dlg,GWLP_USERDATA,(__int3264)(LONG_PTR)56);
     HWND hButton = ::GetDlgItem(Dlg,IDC_LIRE);
    SetWindowLongPtr(hButton,GWLP_USERDATA,(__int3264)(LONG_PTR)56);

I'm finally trying to work this out.

The sample that you gave me work just fine.

I've take a sample project from the web and try to modify it to set the SetWindowLongPtr:

Project

I've set it this way:

SetWindowLongPtr(Dlg,GWLP_USERDATA,(__int3264)(LONG_PTR)56);
    SetWindowLongPtr((HWND)IDC_LIRE,GWLP_USERDATA,(__int3264)(LONG_PTR)56);

When I'm trying to get the value for the button "Lire" from AutoIt I get 0 as value.

But for the window it's equal to 56 as I set it.

MsgBox(0,"", _WinAPI_GetWindowLong($hWnd,$GWL_USERDATA))

Do you know what I'm doing wrong ?

Edited by Vincs
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...