I need to show the windows switcher with SendInput
. Another question I asked explains the reason of doing this. Shortly speaking, when I am holding Alt Tab
to switch to other apps, my app may fire a key stroke using SendInput
, which will interrupt current switcher, and this is why I need to refire a Alt Tab
. Currently I am working on posting another tab
key stroke (I am still holding alt when switching) or the entirely alt down + tab down & up
. But with alt holding, a single tab stroke sent by SendInput will not trigger the switcher. And the entire combined key does not work neither. Here's some test code.
#include <windows.h>
#include <WinUser.h>
#include <iostream>
int main(void) {
Sleep(1000 * 3);
INPUT tabinput[2];
tabinput[0].type = INPUT_KEYBOARD;
tabinput[0].ki = {0x09, 0}; // KEY_TAB = 0x09
tabinput[1].type = INPUT_KEYBOARD;
tabinput[1].ki = {0x09, 0, KEYEVENTF_KEYUP};
SendInput(2, tabinput, sizeof(INPUT));
getchar();
}
I'm trying to fire a tab key stroke delayed 3s. I'am holding the alt key. This doesn't work. But the tab key is triggered, because When I run this code and switch to a text editor or something, there will be a tab event. My system is win8.1 64bit
.