Jump to content

How to catch the ID of an object dynamically?


Silvinho
 Share

Recommended Posts

Hello Silvinho,

Someone gave me this a while back:

Func GetControlID( $hwnd)
    Local $ID = DllCall('user32.dll', 'int', 'GetDlgCtrlID', 'hwnd', $hwnd)
    if IsArray ($ID) Then Return $ID[0]
    Return 0    
EndFunc

Is that what you need?

Zach...

Link to comment
Share on other sites

How to catch the iD of a Tedit Object and to pass as argument in the function

ControlClick ("My Window", "", 254)

This ID always changes, I need take it and to pass in the function above in a variable.

Hello Silvinho,

Someone gave me this a while back:

Func GetControlID( $hwnd)
    Local $ID = DllCall('user32.dll', 'int', 'GetDlgCtrlID', 'hwnd', $hwnd)
    if IsArray ($ID) Then Return $ID[0]
    Return 0    
EndFunc

Is that what you need?

Zach...

Link to comment
Share on other sites

Here's how to use it:

Func GetControlID( $hwnd)
    Local $ID = DllCall('user32.dll', 'int', 'GetDlgCtrlID', 'hwnd', $hwnd)
    if IsArray ($ID) Then Return $ID[0]
    Return 0    
EndFunc

Run ("calc.exe" )
WinWait( "Calculator" )

$hwnd = ControlGetHandle( "Calculator", "", "[TEXT:2]" )
$id = GetControlID( $hwnd );    <---- this gets the control ID of the "2" button
ControlClick ("Calculator", "", $id )
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...