Qt simulates virtual keyboard implementation
Each key has a corresponding hexadecimal number, which is realized through the keybd_event function.
For example, multitasking, Ctrl+Alt+Tab, simulates this shortcut key.
#define EN_KEY_CTRL 0x11 //CTRL
#define EN_KEY_ALT 0x12 //ALT
#define EN_KEY_TAB 0x09 //TAB
void multitask()
{
int nVK[4] = { 0, };
int nVKNum = 0 ;
nVK[0] = (EN_KEY_CTRL);
nVK [ 1 ] = ( EN_KEY_ALT );
nVK [ 2 ] = ( EN_KEY_TAB );
nVKNum = 3 ;
SimulateKeyToSystem(nVKNum, nVK);
}
void SimulateKeyToSystem(int nVKNum, int *nVK)
{
INT32 i = 0 ;
char cExtendFlag = 0;
// Simulate key press message
for (i=0; i<nVKNum; i++)
{
keybd_event(nVK[i], MapVirtualKey(nVK[i], 0), cExtendFlag, 0);
}
for (i=0; i<nVKNum; i++)
{
keybd_event(nVK[i], MapVirtualKey(nVK[i], 0),
cExtendFlag | KEYEVENTF_KEYUP, 0);
}
}