Click to See Complete Forum and Search --> : Have a non foreground window look for a keypress?


Cwetze01
December 15th, 2004, 11:31 PM
Hi,

IS there a way to have for a non foreground application look for a keystroke such as F12?

I am writing a micro program that should look for keystrokes and then copy the prerecored micros to the foreground program. So far my app can send the keystrokes to foreground programs but only if I have it sleep and switch focus to the foreground window. I want to beable to press F12 or whatever and have it do it when I am working in the foreground application.

NoHero
December 16th, 2004, 06:03 AM
You can use 'RegisterHotkey' to define a windows global hotkey your application can handle. Otherwise you may use 'GetAsyncKeyState' to check if a button is pressed, but in this solution you need a loop checking for the F12 key to be pressed.

Cwetze01
December 17th, 2004, 12:03 AM
Thanks. That worked perfectly.

NoHero
December 17th, 2004, 01:57 AM
Thanks. That worked perfectly.

You are welcome! :wave: