Jump to content

WinGetState returns visible


Uten
 Share

Recommended Posts

WinGetState returns a number indicating that a window is visible (WS_VISIBLE flag). Also when it is covered by another window as it is "visible" (WS_VISIBLE is set). Do you have a sugestion on how I can determine if a window, or part of it, is visible to the user (as in not covered by another window)?

$windowID = GUICreate("Visible test")
GUISetState(@SW_SHOW)
local $msg
AdlibEnable("TrackWindow", 3000)
Do
   $msg = GUIGetMsg()
   if $msg = 0 Then Sleep(250)
Until $msg = -3
AdlibDisable()
Exit

Func TrackWindow()
   Global $gTrackWindowPrevState
   Local $WinState
   $WinState = WinGetState($windowID)
   If $WinState <> $gTrackWindowPrevState Then 
      $gTrackWindowPrevState = $WinState
      ConsoleWrite(@Min & ":" & @Sec & " " &  WinGetStateToString($WinState) & @LF)
   Endif
EndFunc
Func WinGetStateToString($state)
   If BitAnd($state, 1) = 1 Then $ret = "EXISTS, "
   If BitAnd($state, 2) = 2 Then $ret = $ret & "VISIBLE, "
   If BitAnd($state, 4) = 4 Then $ret = $ret & "ENABLED, "
   If BitAnd($state, 8) = 8 Then $ret = $ret & "ACTIVE, "
   If BitAnd($state, 16) = 16 Then $ret = $ret & "MINIMIZED, "
   If BitAnd($state, 32) = 32 Then $ret = $ret & "MAXIMIZED, "
   If StringRight($ret, 2) = ", " Then 
      $ret =  StringLeft($ret, StringLen($ret) -2 )
   EndIf
   Return $ret
EndFunc

EDIT: Typo

Edited by Uten
Link to comment
Share on other sites

That's because visible in this case is not the same as "being able to see it", I think you want to check whether it is active, 'cause that's what changes when something covers it.

Regards

Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Link to comment
Share on other sites

That's because visible in this case is not the same as "being able to see it", I think...

Regards

That is about what I tried to say in my first post :)

What I needed to know was if the window (or part of ) is visible but not active. I think I have seen code for this in other languages, but cant recall where and when. Probably as part of some drawing code.

Anyhow, I have found a way around my problem, so it is solved but not through the "IsRealyVisible" way.

Appreciate for your response.

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...