Guest danielwaynekelley Posted September 9, 2005 Posted September 9, 2005 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
Moderators SmOke_N Posted September 9, 2005 Moderators Posted September 9, 2005 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.
seandisanti Posted September 9, 2005 Posted September 9, 2005 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...
Moderators SmOke_N Posted September 9, 2005 Moderators Posted September 9, 2005 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.
seandisanti Posted September 9, 2005 Posted September 9, 2005 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
seandisanti Posted September 9, 2005 Posted September 9, 2005 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...
LxP Posted September 10, 2005 Posted September 10, 2005 (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 September 10, 2005 by LxP
seandisanti Posted September 10, 2005 Posted September 10, 2005 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.
LxP Posted September 11, 2005 Posted September 11, 2005 Hehe, I'm a slacker like that. 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now