Jump to content
Sign in to follow this  

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.

Share this post

Link to post
Share on other sites

I'm currently using class names and instances and I'm seeking for another way to identify component. A more precise way, that is directly linked to the component it self.

Share this post

Link to post
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.


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

$c_Button = GUICtrlCreateButton("Test", 10, 10, 200)

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


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



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

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

$aEnumList = _EnumChildWindows($hWnd)


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


Edited by KaFu

Share this post

Link to post
Share on other sites

Thanks for your help.

Unfortunately I don't have a graphical project in which I can edit the code to set the SetWindowLong.

I will try this in a short time.

Share this post

Link to post
Share on other sites

Sorry the delay.


Ok my bad I wasn't setting the button correctly

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

     HWND hButton = ::GetDlgItem(Dlg,IDC_LIRE);

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:


I've set it this way:


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

Share this post

Link to post
Share on other sites

Sorry, I'm not familiar with c, better ask this question in the developer forum.

I edited my topic.

It works, thanks to you !

Share this post

Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...