Aha! I’ve figured it out. If ahk and the target app are not running under the same privileges (or user) ahk won’t intercept/simulate keyboard events properly. In my case, visual studio was run with administrator (elevated) privileges while the ahk script was run as the currently logged on user.
Either of the following solved the problem:
- Running both vs and ahk as the current user
- Compiling the script and running both vs and the compiled app as administrator