Jump to content

Detect A Truly Visible Window


kjcdude
 Share

Recommended Posts

I'm looking for a function that can detect when a window is visible by the human eye.

I know that WinGetState() will return if it exists, is "visible", enabled, and active.

But that doesn't tell me if the window is covered or if it's visible by the human eye.

From the tests I've run it will only return 7 even if the window is covered by another application, even a full screen application.

The good thing is the window I'm monitoring is inside a script, so if I need to use a gui function that won't be a problem.

Thanks for the help.

Link to comment
Share on other sites

To see if a window is visible maybe you could do something like this.

For each corner of the window use WindowFromPoint to see which is the topmost window and then if it is another window get the edges of that window and test where that crosses the border of your window etc.

But could you simply force your window to the top using WInSetOnTop?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

To see if a window is visible maybe you could do something like this.

For each corner of the window use WindowFromPoint to see which is the topmost window and then if it is another window get the edges of that window and test where that crosses the border of your window etc.

But could you simply force your window to the top using WInSetOnTop?

WindowFromPoint was exactly what I was looking for, worked perfectly.

Little example of how I used it.

#include <WinAPI.au3>

Global $Struct = DllStructCreate($tagPoint)

DllStructSetData($Struct, "x", 805)
DllStructSetData($Struct, "y", 234)

$mhwnd = _WinAPI_WindowFromPoint($Struct)

while 1
    Pos()
    $hwnd = _WinAPI_WindowFromPoint($Struct)
    if $mhwnd <> $hwnd Then
        MsgBox(0, "", "on top")
    EndIf
    ToolTip($hwnd & @CRLF & MouseGetPos(0) & " X " & MouseGetPos(1))
WEnd

Func Pos()
    DllStructSetData($Struct, "x", MouseGetPos(0))
    DllStructSetData($Struct, "y", MouseGetPos(1))
EndFunc   ;==>Pos
Edited by kjcdude
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...