Jump to content

Recommended Posts

Posted

Hello, I am new to AutoIT (just got it yesterday) and I am already loving it, but I am having a little trouble.

I am trying to automate my way through a program, but I do not wish to use the MouseClick command. I am trying to use the ControlClick command, however, the ControlID on the object I need to click on is dynamic and it changes everytime the program runs.

I am wondering if there is a script that can be written to get the ControlID of an object and return it in a variable that I can place in the ControlClick command...

for example:

Dim $CtrlID

*YayGetTheControlIDScript*

ControlClick("Management Form", "", "$CtrlID")

can this be done?

Any help would be greatly appreciated.

Posted

have a look at ANYGUI in my signature...

_GuiTarget( ) will accept x and y coordinates of a point that falls within a particular control(in CLIENT coords) and get the hwnd to it. Those .Net apps are such a pain.....

[u]Do more with pre-existing apps![/u]ANYGUIv2.8
Posted (edited)

Both good suggestions, however, the coordinates of the window change every time it is initialized, and the ClassName changes as well as the ControlID...

what's a guy to do?

Is there a way to tell the control a proposed coordinate from say, the top left corner of the window?

so instead of it being a coordinate from the entire screen, it measures the x and y values from the corner of the currently active window? (if this isn't possible now, I think this should definitely be implemented somewhere in a future version)

Edited by DakotaSmyth
Posted (edited)

I really just need a way to find the ControlID of an object (such as a textbox) so i can read what's typed into the object, compare what was read to text I have in another file, and then create a logfile of whether they matched or didn't.

Edited by DakotaSmyth
Posted

Your ANYGUI signature got me to understand the concept (very well put together, btw :whistle: ), but what I am trying to do is get the ControlID for an object that I didn't create and that is automatically made when the program starts what I'm trying to do is all user-based. I'm not trying to create my own GUI, I'm trying to read others.

Posted (edited)

use Client coords with _GuiTarget() [its an option in Au3Info tool]

doesn't have to add anything, but it will get the hwnd to the control.....if you study the function there's a snippet in ther to get the ControlId (though most Autoit func's will accept hwnd in place of controlid.)

Edited by quaizywabbit
[u]Do more with pre-existing apps![/u]ANYGUIv2.8
  • 3 weeks later...
Posted

If you have hwnd then you can use this code:

;===============================================================================
; Function Name:    GetDlgCtrlID
; Description:            Get CtrlId from Handle
; Parameter(s):        $hwnd    Handle of control
; Requirement(s):    
; Return Value(s):    Control Id on success, 0 on failure
; Author(s):
;===============================================================================
Func _GetDlgCtrlID($hwnd)
    $ID = DllCall('user32.dll', 'int', 'GetDlgCtrlID', 'hwnd', $hwnd)
    if IsArray ($ID) Then Return $ID[0]
    Return 0
EndFunc   ;==>GetDlgCtrlID

So long.

  • 1 month later...
Posted

But I don't have Control Handle

So How should I get Control Handle?

Thank you!!

If you have hwnd then you can use this code:

;===============================================================================
; Function Name:    GetDlgCtrlID
; Description:            Get CtrlId from Handle
; Parameter(s):        $hwnd    Handle of control
; Requirement(s):    
; Return Value(s):    Control Id on success, 0 on failure
; Author(s):
;===============================================================================
Func _GetDlgCtrlID($hwnd)
    $ID = DllCall('user32.dll', 'int', 'GetDlgCtrlID', 'hwnd', $hwnd)
    if IsArray ($ID) Then Return $ID[0]
    Return 0
EndFunc   ;==>GetDlgCtrlID

So long.

Posted

maybe this will help?

Classname from position

$hwnd = ControlGetHandle ( "title", "text", controlID ) ;classname will work

_GetDlgCtrlID($hwnd)

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
  • Recently Browsing   0 members

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