Sign in to follow this  
Followers 0
Vincs

Window Info Control:Name in C++ Win32

8 posts in this topic

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



Names are only used by .Net controls, you want to use the stuff under "Windows Titles and text (advanced)" in the helpfile. You could use class names and instances for example.

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

#4 ·  Posted (edited)

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

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

#6 ·  Posted (edited)

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

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  
Followers 0