What to do when "A" getting the current active window misses?
Posted: 13 Jan 2024, 18:41
There's a non-zero chance that any code that uses "A" will bring up a Target not found error. It's not clear to me why it fails, seemingly randomly, but should there be a best practice or some codebase change to mitigate this error?
For example, often simple code like:
just fails.
It's not clear to me that each line of code that contains "A" should be systematically wrapped in try {} catch TargetError {return} when there's something wrong with the notion of "A" having a 0.1% chance of failing. As far as the regular user is concerned, there is always an active window. In other words, I don't see why even catching a TargetError could even possibly be a solution to this problem, when the WinTitle could be an ahk_id, throwing a legitimate TargetError. That shouldn't be overlapped with "A" throwing a bs TargetError which has zero meaning to myself or anyone else.
For example, often simple code like:
Code: Select all
; Closes the window
PostMessage 0x112, 0xF060,,, 'A' ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
It's not clear to me that each line of code that contains "A" should be systematically wrapped in try {} catch TargetError {return} when there's something wrong with the notion of "A" having a 0.1% chance of failing. As far as the regular user is concerned, there is always an active window. In other words, I don't see why even catching a TargetError could even possibly be a solution to this problem, when the WinTitle could be an ahk_id, throwing a legitimate TargetError. That shouldn't be overlapped with "A" throwing a bs TargetError which has zero meaning to myself or anyone else.