how do combination keys with SendMessage()?

Mar 21, 2016 at 9:28pm
using SendMessage() with WM_KEYDOWN, how i can combine keys?
Mar 22, 2016 at 11:01am
I don't understand the question as such, but if you run Spy, you can see the message sequences and copy it.
Mar 22, 2016 at 11:46am
I would guess that you mean something like ctrl+A? They are two separate message. When someone presses the keys on the keyboard you receive also two messages.

What you probaly have to do is sending a WM_KEYUP message as well.
Mar 22, 2016 at 12:29pm
Coder777: are you tell me that i need SendMessage() for 'A' and for ctrl keys?
so how i do that steps? is like SendInput()?
(my problem with SendInput() is that i can't choose the window. why these? because when i lose the focus, on window, the SendInput() will have effect on other window)
Mar 22, 2016 at 1:01pm
are you tell me that i need SendMessage() for 'A' and for ctrl keys?
Yes.

so how i do that steps?
Call the SendMessage() two times with the different appropriate messages.

is like SendInput()?
It has some similarities, but you need to pack it in wParam/lParam. See:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms646280%28v=vs.85%29.aspx

Again: WM_KEYDOWN allone might not suffice. You might need WM_KEYUP. Just test it.
Mar 22, 2016 at 4:27pm
i did these function:
1
2
3
4
5
6
7
8
9
10
11
void SendInputkey(HWND window, WORD key, WORD shift=0)
{
    if(shift!=0)
        SendMessage(window, WM_KEYDOWN,(WPARAM) shift,0);
    SendMessage(window, WM_KEYDOWN,(WPARAM) key,0);


    SendMessage(window, WM_KEYUP,(WPARAM) key,0);
    if(shift!=0)
        SendMessage(window, WM_KEYUP,(WPARAM) shift,0);
}

for now, i don't get any results :(
Mar 23, 2016 at 9:03am
I can't say what the problem is, sorry. Maybe it is sending down/up directly one after the other will be ignored?

Maybe the target does not even care for what you send and use other function to determine the state of the keyboard.

Well:

https://blogs.msdn.microsoft.com/oldnewthing/20050530-11/?p=35513/
Mar 23, 2016 at 2:10pm
maybe you have right. i will do a diferent topic for SendInput().
thanks to all
Mar 26, 2016 at 1:44am
Another issue might be there is no delay. Maybe try adding Sleep(100); before doing key up. I'm not sure if this helps because I don't know what you will be using this for.
Mar 26, 2016 at 10:58am
drowsysaturn: i belive you have right. but i continue with same problem:
SendInput() or SendMessage() or PostMessage() only works when the window have focus.
don't make sence that we don't have 1 function that realy calls a keyboard message, when the window don't have focus :(
Topic archived. No new replies allowed.