Log in

View Full Version : Emulating Function Keys


AngelPR
05-14-2003, 09:48 PM
I need to emulate the function keys on a pocket pc? How can i do this?

Thanks;

Angel

Ian Hanschen
05-21-2003, 05:06 PM
Use SendInput() with the virtual key code of the button you're interested in.

The hardware buttons are not defined in the public winuser.h, here are the defines:

#define VK_APP_LAUNCH1 0xC1
#define VK_APP_LAUNCH2 0xC2
#define VK_APP_LAUNCH3 0xC3
#define VK_APP_LAUNCH4 0xC4
#define VK_APP_LAUNCH5 0xC5
#define VK_APP_LAUNCH6 0xC6
#define VK_APP_LAUNCH7 0xC7
#define VK_APP_LAUNCH8 0xC8
#define VK_APP_LAUNCH9 0xC9
#define VK_APP_LAUNCH10 0xCA
#define VK_APP_LAUNCH11 0xCB
#define VK_APP_LAUNCH12 0xCC
#define VK_APP_LAUNCH13 0xCD
#define VK_APP_LAUNCH14 0xCE
#define VK_APP_LAUNCH15 0xCF

The best way to figure out which button does what on your device(sorry, I don't know them offhand) is to just use spy++ on the foreground window and use said button. Then look at the keyboard message sent, grab the VK_ keycode, and use that.

So as an example:

INPUT input;
memset(&input, 0, sizeof(INPUT));
input.type = INPUT_KEYBOARD;
input.ki.dwExtraInfo = 0;
input.ki.wVk = VK_APP_LAUNCH1;
SendInput(1, &input, sizeof(INPUT));
input.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &input, sizeof(INPUT));

The above code causes that button to be virtually 'pressed' and 'released'.
Note that the power button is special, it's VK_OFF.