'Alter Keystate of Shift while using PostMessage

I'm currently trying to experiment with using PostMessage.

I got the hang of how to use it and apply different keys and such but I've met a problem: When using PostMessage while I myself am pressing Shift or Ctrl, it will be a combined Keypress of Shift + Key.

In some situations this isnt optimal or actually wrong and I was wondering if it's possible to either ignore the Keystate of Shift or set it to No through Flags or something

        PostMessage(hWnd, WM_SYSKEYDOWN, VK_S, 0);
        PostMessage(hWnd, WM_SYSKEYUP, VK_S, 0);

I'm using it like this. I've tried using WM_KEYDOWN and UP or WM_CHAR but it seems like my application doesn't react to WM_CHAR and WM_KEYDOWN does the same as WM_SYSKEYDOWN



Solution 1:[1]

Don't try to synthesize keyboard (or mouse) messages directly. Use SendInput instead.

Note, however, that this will still add the new input to the end of the message queue, so if you want to act like a certain key combination is pressed right now you will need to handle that situation in some other manner.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SoronelHaetir