Owtch...
my sincere apologies to
@Lexicos and the team for my completely ignorant claim that Window Spy for AHKv2 has a problem and that the other tools I mentioned do not. If anything, it is the other way around!
My current findings/suspicions: when a script is stopped due to a breakpoint in the debugger, it becomes unresponsive as far as Windows is concerned. In order to make it possible for a user to minimize, move, or close the main window of an application that is not responding, Windows implemented Window Ghosting in the Windows Manager which captures whatever it can from the unresponsive window on the screen and creates a new ghost window (class 'ghost').
Although Spy++ and CV detect and return info from the ghost window, the property values can be misleading (as they were to me) e.g. HWND is for the ghost window, not the Gui window I am debugging.
So Windows Spy essentially ignoring the ghost window has its advantages
HWND of actual Gui window I'm debugging: 91D4A
HWND of Ghost Window: A1D9C
- image.png (63.46 KiB) Viewed 252 times
More info:
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-disableprocesswindowsghosting
https://www.autoitscript.com/forum/topic/79222-ghost-class-window/?do=findComment&comment=571362
Would appreciate if any more knowledgeable can comment/confirm I've got that right and that the only way to get the correct property values from a "Spy" tool during debugging is by pausing the script