Sign in to follow this  
Followers 0
newbiescripter

How to get ControlID?

4 posts in this topic

#1 ·  Posted (edited)

Hello

My problem is that. when I try to controlclick on a specific button in the program then it works fine if I take the controlID and run the script, but when I then close the program, open it up again and then try running the script again it will not click on the button.

I have found out that it is because the ControlID and the ClassnameNN is changing every time the program is restarting.

So I need to find a way to get the controlID in the beginning of my script. Just like PixelGetColor - this will return the specific color in that pixel.

like this I need the ControlID on the button in that pixel.

Hope you understand what I mean and that it is possible :)

Regards

Edited by newbiescripter

Share this post


Link to post
Share on other sites



Hello

My problem is that. when I try to controlclick on a specific button in the program then it works fine if I take the controlID and run the script, but when I then close the program, open it up again and then try running the script again it will not click on the button.

I have found out that it is because the ControlID and the ClassnameNN is changing every time the program is restarting.

So I need to find a way to get the controlID in the beginning of my script. Just like PixelGetColor - this will return the specific color in that pixel.

like this I need the ControlID on the button in that pixel.

Hope you understand what I mean and that it is possible :)

Regards

What remains constant in the control: Text, Location, Class, ...?

You can use the advanced match modes to find it. For example, if the the Class was always NewFunkyButton, but the instance kept changing, and the text was always "Click Here":

ControlClick("Window Title", "Optional Text", "[CLASS:NewFunkyButton; TEXT:Click Here]")

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

There is unfortunaly no text in the control and the class is also changing and so are the ID.

The location is always the same. on mousecoord (120,50) in the window, so I could use mouseclick, but i just doesn't find this as the right solution.

Share this post


Link to post
Share on other sites

There is unfortunaly no text in the control and the class is also changing and so are the ID.

The location is always the same. on mousecoord (120,50) in the window, so I could use mouseclick, but i just doesn't find this as the right solution.

Then you are down to enumerating the control classes with WinGetClassList() and then walking the array, testing for multiple instances of each class, and testing the position of each control for a match. It will help if there are any common elements or patterns in the class name, as this would allow a better RegExp type test of the class name, but it could be done purely on position.

I believe SmOke_N posted a UDF for this, something like ControlGetHandleByPos() (not the exact name).

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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