Jump to content

Customized Winwait/winwaitactive Udf


Recommended Posts

I was looking for some help with the WinGetState command and how to best interpret it's return value.

Success: Returns a value indicating the state of the window. Multiple values are added together so use BitAND() to examine the part you are interested in:

1 = Window exists

2 = Window is visible

4 = Windows is enabled

8 = Window is active

16 = Window is minimized

32 = Windows is maximized

 

Failure: Returns 0 and sets @error to 1 if the window is not found.

I'm thinking I'd like to interpret this return value as binary; for example Window exists & Window is enabled :: 1 + 4 = 5 :: 101.

Then I'd like to compare these binary values with the BitAND, BitOR, BitNOT, etc. functions, but I'm having a Bit of trouble (pun intended).

Now, on with the questions:

Is there a difference between 101 and 00101 (and 000000101) ?

Is there a way to set up conditional statements so that reguardless of minimized/maximized/enabled, I can continue on as hoped? i.e. I only care that 1011 these positions are 1's?

Thank you for your time.

Link to comment
Share on other sites

From the example you posted of the binary you want to check for, it looks like you only care if the Window Exists, is Visible and is Active. If that is the case, then you really only need to check to see if it is Active because it's implied that it exists if it's active, and it also implies that it's visible if it's active (An invisible Window can't be active in Windows as far as I know). So this should work (Untested):

$state = WinGetState("My Window")
If BitAND($state, 8) Then
   ; Window is active, do stuff
Else
   ; Window was not active, do something else
EndIf
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...