Another problem is that I wanted to have this also work for Troy's situation where he wanted to do things like push F9 for Spindle On CW from a KFLOP initiated command. That works fine except if another Windows App is active instead of KMotionCNC. So if you are working in KMotion.exe or Notepad.exe pushing Troy's Spindle On CW physical button wouldn't work, and the other app might respond to F9 and do something odd.
I thought it would be easy to just Activate KMotionCNC then send the keystroke. But Microsoft basically forbids any App from making itself Active. I guess the concern is that someone might be typing an email and all of a sudden their keystrokes start going to a different application.
So I'm starting to think all this Auto Keyboard stuff is a bad idea. But I haven't given up just yet. If anyone has some ideas I'm open.