Hello.
Is there a reliable way to check whether a window is fully covered behind other windows?
I have a small window which is kept non-activated in the right side of the screen, next to another focused window. That small window sometimes gets hidden behind other windows, and I need to manually bring it in front, next to the main window. I want to automate this process with AHK, but I dont know how to trigger it only when that window gets hidden.
I have tried to put it in AlwaysOnTop, but that conflicts with the other windows, so I want to avoid this approach.
I cant use WinGet to check if it gets minimized, because it doesnt, it stays opened and only goes behind the other windows.
Checking for a specific color or pixel on the window is not reliable, and I want to avoid it.
I tried the suggestions from this topic, but none works:
https://autohotkey.com/board/topic/58933-how-to-check-if-a-window-is-hidden/
There is also this post discussing this, but again not much of a help:
https://www.autohotkey.com/boards/viewtopic.php?t=4045
Any other idea how I can do this?
How to check if a window is fully behind others? Topic is solved
Re: How to check if a window is fully behind others?
You could use this:
check if rectangles (windows) overlap - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=30809
In the worst-case scenario, a window is *partially* overlapped by another window, and you then have multiple smaller rectangles (the non-overlapped parts), and you have to check if those are overlapped. And this process can repeat, with multiple small bits of window to check.
check if rectangles (windows) overlap - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=30809
In the worst-case scenario, a window is *partially* overlapped by another window, and you then have multiple smaller rectangles (the non-overlapped parts), and you have to check if those are overlapped. And this process can repeat, with multiple small bits of window to check.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
-
- Posts: 264
- Joined: 09 Mar 2019, 01:52
- Location: Germany
- Contact:
Re: How to check if a window is fully behind others?
You could get the window position using WinGetPos, and then do MouseGetPos at various points (or DllCall with WindowFromPoint) to get the window under the cursor.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: How to check if a window is fully behind others? Topic is solved
Hi KilliK,
Would you let me know if the code below works for you?Cheers!
- iPhilip
Would you let me know if the code below works for you?
Code: Select all
F3:: ; Set the window to keep active and start the timer
hwnd := WinExist("A")
SetTimer, Timer, 100
Return
Timer:
WinGet, ID, List, , , Program Manager
Loop, %ID% {
if (ID%A_Index% = hwnd)
Break
if IsWinCover(ID%A_Index%, hwnd) {
WinActivate, ahk_id %hwnd%
Break
}
}
Return
; Returns true if hwnd1 completely covers hwnd2
IsWinCover(hwnd1, hwnd2) {
WinGetPos, X1, Y1, W1, H1, ahk_id %hwnd1%
WinGetPos, X2, Y2, W2, H2, ahk_id %hwnd2%
Return X1 <= X2 && Y1 <= Y2 && X1+W1 >= X2+W2 && Y1+H1 >= Y2+H2
}
Esc::ExitApp
- iPhilip
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
Re: How to check if a window is fully behind others?
iPhilip, I checked your code and it works very well, it does exactly what I need. thank you very much.
Re: How to check if a window is fully behind others?
You are very welcome.
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
Who is online
Users browsing this forum: mebelantikjaya and 279 guests