c - How can I simulate key presses to any currently focused window? -


I'm trying to change the keys to my keyboard applications I've already created a global hook and which keys I I want to stop it, but now I want to send a new key in place. Here is my hook process:

  LRESULT __declspec (dllexport) hookproc (int nodod, varm WPARM, LAPRM LPARM) {int rate; If (nCode & lt; 0) {return CallNextHookEx (hHook, nCode, wParam, lParam); } KbStruct = (KBDLLHOOKSTRUCT *) lParam; Printf ("\ n caught [% x]", kbStruct-> vkCode); If (kbStruct-> vkCode == VK_OEM_MINUS) {printf ("- less than zero!"); Key_events (VK_DOWN, 72, KIVEVENT_KEYUUP, Faucet); Return -1; } And if (kbStruct-> vkCode == VK_OEM_PLUS) {printf ("-om plus!"); Key_events (VK_UP, 75, KIVEVENT_KEYUUP, null); Return -1; } Return CallNextHookEx (hHook, ncode, wParam, lParam); }  

I have tried to use SendMessage and PostMessage with GetFocus () and GetForegroudWindow (), but can not detect the creation of LPARAM for WM_KEYUP or WM_KEYDOWN. I also tried Keyword (), which simulates keys (I know because it holds the hook-proof simulated key press), which includes 5 or 6 different scan codes, but nothing affects my foreground window Does.

Basically my MS 3200 is trying to change the zoom bar into the scroll control, so I can also send the wrong key (UP and down).

Calling keybd_event is correct. If what you're doing is a key, the window instead processes the message below the key, you actually need to send a key down one key below:

  keybd_event (VK_UP , 75, 0, NULL); Key_events (VK_UP, 75, KIVEVENT_KEYUUP, null); Or, better yet, the OEM key goes down when the key goes down and an OEM key goes up when the key up keys you key up / down state kbStruct-> flags & Amp; Can tell by; LLKHF_UP 


Comments