Check if window is visible (not active)

Get help with using AutoHotkey and its commands and hotkeys
nallar
Posts: 2
Joined: 22 Jul 2014, 19:28

Check if window is visible (not active)

22 Jul 2014, 19:31

How do you check if a window is visible (any part of it is not hidden behind other windows)?

For example, if I have a Chrome window open, with a notepad window in front of it covering part of the window, both windows would count as visible.

If the notepad window was then maximised, the chrome window would no longer count as visible.
Guest

Re: Check if window is visible (not active)

23 Jul 2014, 05:07

Failing that, is it possible to get the depth of a window, or iterate through them in order of depth?

That way I could implement this myself iterating the windows in depth order and checking if their areas overlap to determine which are visible.
strobo
Posts: 125
Joined: 30 Sep 2013, 15:24

Re: Check if window is visible (not active)

23 Jul 2014, 05:15

Hi,
ahk has no direct command to return the z-order of windows, maybe this helps (with dllcall):
http://stackoverflow.com/questions/8255 ... in-windows
But, ahk could do everything else required directly (winget, wingetpos, winexist, calculations).
nallar
Posts: 2
Joined: 22 Jul 2014, 19:28

Re: Check if window is visible (not active)

23 Jul 2014, 05:26

strobo wrote:Hi,
ahk has no direct command to return the z-order of windows, maybe this helps (with dllcall):
http://stackoverflow.com/questions/8255 ... in-windows
But, ahk could do everything else required directly (winget, wingetpos, winexist, calculations).
Thanks for that tip, I had been googling for AHK specific ways instead of just looking for how to do it in general and using DllCall.

Found this http://bobmoore.mvps.org/Win32/w32tip72.htm , I'll post a reply here with an AHK function once I get it working, in case someone else wants to do this.
just me
Posts: 6805
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Check if window is visible (not active)

23 Jul 2014, 06:34

WinGet
List:
Retrieves the unique ID numbers of all existing windows that match the specified WinTitle, WinText, ExcludeTitle, and ExcludeText (to retrieve all windows on the entire system, omit all four title/text parameters). ... Windows are retrieved in order from topmost to bottommost (according to how they are stacked on the desktop). ...
strobo
Posts: 125
Joined: 30 Sep 2013, 15:24

Re: Check if window is visible (not active)

23 Jul 2014, 07:24

What?! :o ;) for some reason it wasn't in memory. Maybe, because I have tested and neglected it (idk why) some (long) time ago --- just found it (holy grep):

Code: Select all

coordmode,mouse,screen
esc::exitapp
!tab::
	MouseGetPos,x,y
	WinGet, sWinList, List
	loop,% swinlist
		if (a_index > 3 && px <= x && x <= px+dx && py <= y && y <= py+dy){
			wingettitle,title,% "ahk_id " sWinList%a_index%
			msgbox,% title
			break
		}
return
Thanks for the reminder!

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], clarsondd, Google [Bot], PuzzledGreatly and 336 guests