Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

SendInput and VK_SHIFT using C++

SendInput and VK_SHIFT using C++

SendInput and VK_SHIFT using C++

I'm trying to use SendInput to send keystrokes from my application to another application in a different thread.

I can accomplish sending character keys without a problem.

The problem arises when I try to send, non-character keys, specifically VK_SHIFT. The target application simply doesn't respond to the shift key when using SendInput.

I've searched and read everything I can find, trying everything including AttachThreadInput and Get/SetKeyboardState. Nothing seems to work, so I'd like to start over and see if anyone on this site can help provide a solution.

Here's the code that I used at the beginning of this project:
INPUT arrayKeyBDIn[5];
arrayKeyBDIn[0].type = INPUT_KEYBOARD;
arrayKeyBDIn[0].ki.dwExtraInfo = 0;
arrayKeyBDIn[0].ki.time = 0;
arrayKeyBDIn[1].type = INPUT_KEYBOARD;
arrayKeyBDIn[1].ki.dwExtraInfo = 0;
arrayKeyBDIn[1].ki.time = 0;
arrayKeyBDIn[2].type = INPUT_KEYBOARD;
arrayKeyBDIn[2].ki.dwExtraInfo = 0;
arrayKeyBDIn[2].ki.time = 0;
arrayKeyBDIn[3].type = INPUT_KEYBOARD;
arrayKeyBDIn[3].ki.dwExtraInfo = 0;
arrayKeyBDIn[3].ki.time = 0;

//Set up a SHIFT 0 (zero)
arrayKeyBDIn[0].ki.wVk = VK_SHIFT;
arrayKeyBDIn[0].ki.wScan = MapVirtualKey(VK_SHIFT, 0);
arrayKeyBDIn[0].ki.dwFlags = KEYEVENTF_SCANCODE;

arrayKeyBDIn[1].ki.wVk = 0x30;
arrayKeyBDIn[1].ki.wScan = MapVirtualKey(0x30, 0);
arrayKeyBDIn[1].ki.dwFlags = KEYEVENTF_SCANCODE;

arrayKeyBDIn[2].ki.wVk = 0x30;
arrayKeyBDIn[2].ki.wScan = MapVirtualKey(0x30, 0);
arrayKeyBDIn[2].ki.dwFlags =

arrayKeyBDIn[3].ki.wVk = VK_SHIFT;
arrayKeyBDIn[3].ki.wScan = MapVirtualKey(VK_SHIFT, 0);
arrayKeyBDIn[3].ki.dwFlags =

//Make target window have focus and send keys
SendInput(4, arrayKeyBDIn, sizeof(INPUT));
This code will work when Notepad is the target window, but not for another application that I am attempting to use that is not a microsoft product.

Anyone have experience with this type of application?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close