08-04-2020 10:29 PM
You want the active window, but you are calling the GetForegroundWindow. Why not calling the GetActiveWindow?
Foreground window ≠ active window.
Foreground window may belong to another application; while active window belongs to the same application.
08-05-2020 01:29 AM
Sorry, I meant foreground window. 🙂