Jump to content

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


Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
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

;...
Link to comment
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
 Share

  • Recently Browsing   0 members

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