i am trying to send a WM_INPUT-message to an application, but i encounter a few hurdles which i fail to solve. I've created the RAWINPUT-structure like the following:
//try sending 'W'
RAWINPUT raw = {0};
char c = 'W';
//header
raw.header.dwSize = sizeof(raw);
raw.header.dwType = RIM_TYPEKEYBOARD;
raw.header.wParam = 0; //(wParam & 0xff =0 => 0)
raw.header.hDevice = hDevice;
//data
raw.data.keyboard.Reserved = 0;
raw.data.keyboard.Flags = RI_KEY_MAKE; //Key down
raw.data.keyboard.MakeCode = static_cast<WORD>(MapVirtualKeyEx(c, MAPVK_VK_TO_VSC, GetKeyboardLayout(0)));
raw.data.keyboard.Message = WM_KEYDOWN;
raw.data.keyboard.VKey = VkKeyScanEx(c, GetKeyboardLayout(0));
raw.data.keyboard.ExtraInformation = 0; //???
//Send the message
SendMessage(hPSWnd, WM_INPUT, 0, (LPARAM)raw/*Raw input handle*/); //TODO: Handle to raw input
Where i get stuck at are at least two positions:
Is there a need to pass something special to
raw.data.keyboard.ExtraInformation
, or is itGetMessageExtraInfo()
, or is there no need to pass anything in here?The LPARAM-parameter of the WM_INPUT-message contains a handle to a RAWINPUT-structure not an address or the structure itself... How to create such a handle?
I do not want to use SendInput, because it requires the window to be the active window. I already did this, and it worked fine, but when i activated another window - of course - it stopped working on the previous one.
So what I am trying to achieve is, sending input to an application that does not need to be the active one.
SendInput
function? – Xylograph