Sign in to follow this  
Followers 0
level20peon

(solved) Check if Specific instance of a Class exists ?

6 posts in this topic

#1 ·  Posted (edited)

I have been trying to write a script which clicks on button a if it exists or button b if button a and b exist.

Without success.

Both buttons have the same class, so I searched for a method to determine whether or not a specific instance of a class exists in a window. Doesn't seem to be the case.

WinGetClassList() didn't help since there it doesn't return instance information.

How would one check for a class instance to exist ?

Edited by level20peon

Share this post


Link to post
Share on other sites



Search the help file for "Window Titles and Text (Advanced)". You'll see that you can reference windows or controls by instance.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I created a workaround by checking for the instance text with ControlGetText() which I use to compare the output strings.

I still am interested if there is a more elegant way to check for the existence of class instances though.

EDIT: you replied when I composed this post. I will see if I find additional information here.

EDIT2: I didn't find a way to check for an instances existence using the "Window Titles and Text (Advanced)" information.

I tried something like this

WinWaitActive("[TITLE:WindowTitle; CLASS:ClassXYZ; INSTANCE:1]", "")

Subsequently an "if WinExists(...)" doesn't throw results either.

Any idea what I'm doing wrong here ?

Edited by level20peon

Share this post


Link to post
Share on other sites

Should I have replied to my own post ?

Share this post


Link to post
Share on other sites

You're not waiting for a window, you're waiting for a specific control to appear on that window:

$hwnd = WinGetHandle('Window Title') ; Case sensitive, so take it into consideration.
$hButton = 0

Do
   $hButton = ControlGetHandle($hwnd, '', 'Button2') ; The second instance, shorthand for '[CLASS: Button; INSTANCE:2]'.
   Sleep(50)
Until $hButton

;...

Share this post


Link to post
Share on other sites

I see this makes sense. Thanks for your explanation.

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