Sign in to follow this  
Followers 0
Guest danielwaynekelley

Function for getting ControlID using Control Text

9 posts in this topic

I am trying to write a function that will allow me to pass wif title, text, and button text to another function that will click that button using the controlclick command. I have tried searching forums for others that might have run into this problem before (seems like it would be a pain for others also) but have thus far been unsuccessfull. It appears that every control command requires a controlid. So far, the only way i have been able to see the controlid is by using the window spy. i would like to automate the scraping of controlid in contrast to the control text. any thoughts?

Thank you in advance for your time.

Dan

Share this post


Link to post
Share on other sites



I've read this thing 4 times, and still can't make heads or tales of it:

LxP has made a UDF that returns control handles via x and y coords.

I'm not quite sure if that is a similar path that you're trying to take, but here is the link:

_ControlGetHandleByPos(), Find a control by its position


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

I've read this thing 4 times, and still can't make heads or tales of it:

LxP has made a UDF that returns control handles via x and y coords.

I'm not quite sure if that is a similar path that you're trying to take, but here is the link:

_ControlGetHandleByPos(), Find a control by its position

<{POST_SNAPBACK}>

i think i can whip something up to find to do what he wants. he's trying to find a button by the text on it, and have the control id returned. since controls are technically windows, i think this can be done...i'm going to play with this a little because it sounds interesting...

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

i think i can whip something up to find to do what he wants.  he's trying to find a button by the text on it, and have the control id returned.  since controls are technically windows, i think this can be done...i'm going to play with this a little because it sounds interesting...

<{POST_SNAPBACK}>

Ahh, Now that makes sense. I don't see the problem with it other than if another window title matches it. I'll play around too ;).

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Ahh, Now that makes sense.  I don't see the problem with it other than if another window title matches it.  I'll play around too ;).

<{POST_SNAPBACK}>

here's what i've got so far:

FileDelete("winlistoutput.txt");delete old output file
$output = fileopen("winlistoutput.txt",1);create output file
Dim $winlist
$winlist  = WinList(); get list of active windows
for $x = 1 to $winlist[0][0];for each window returned
    FileWriteLine($output,@crlf & $winlist[$x][0] & ":   :" & WinGetClassList($winlist[$x][1]) & ":   :" & WinGetText($winlist[$x][1]));puts a blank line between window info
Next

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

here's what i've got so far:

FileDelete("winlistoutput.txt");delete old output file
$output = fileopen("winlistoutput.txt",1);create output file
Dim $winlist
$winlist  = WinList(); get list of active windows
for $x = 1 to $winlist[0][0];for each window returned
    FileWriteLine($output,@crlf & $winlist[$x][0] & ":   :" & WinGetClassList($winlist[$x][1]) & ":   :" & WinGetText($winlist[$x][1]));puts a blank line between window info
Next

<{POST_SNAPBACK}>

well there is definitely a way to access and display the control id within the windows api, that is evidenced by the autoit window info's ability to do just that. so far i've been unable to find documentation on a method in the platform sdk that returns the information we're looking for. right now i'm still digging through the sdk documentation but i'm going to be out of here for the day in a few minutes... maybe we could beg for dev help on this one since they've already skinned the cat once with the window info tool...

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Welcome to the forums Dan!

According to the Controls topic in the help file, you can actually just use button text in the Control...() commands. I just tried opening my Windows Run box and dismissing it with this line of code:

controlClick("Run", "", "Cancel")

and it works as expected.

Edit: Just for anyone who cares, the control ID of a window component does not actually change across different invocations of the window (although .NET applications seem not to adhere to this theorem).

Edited by LxP

Share this post


Link to post
Share on other sites

Welcome to the forums Dan!

According to the Controls topic in the help file, you can actually just use button text in the Control...() commands. I just tried opening my Windows Run box and dismissing it with this line of code:

controlClick("Run", "", "Cancel")

and it works as expected.

Edit: Just for anyone who cares, the control ID of a window component does not actually change across different invocations of the window (although .NET applications seem not to adhere to this theorem).

<{POST_SNAPBACK}>

SURE.... take the easy way out... i'm still trying to find a way to return the control id though.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

Hehe, I'm a slacker like that. :P

You may not have much luck programmatically determining the ID of a control -- this was my initial intention for _ControlGetHandleByPos() but as you can see, I ended up returning a handle. ;)

I suppose that what gets returned doesn't matter too greatly as long as you can use the result to uniquely identify a control.

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