VC++ keybd_event and VK_SHIFT problem

R

roshan

All,

Hello. I am a Software Developer currently creating an emulation
program for our company's System Administrator. He will be able to
call the program and emulate any keyboard combination, or at least
that's the goal. Problem is I am having severe troubles emulating
Shift key combos like (Shift key + End) for example. Nothing happens!
Some combos work such as Shift key + h which gives 'H'. The problem is
more specifically related with emulating the highlighting of characters
which is done for copying or cutting text. The OS I am using is
Windows 2000. Just to let you view a snippet of the code I'm trying to
execute, here it is:

keybd_event(VK_SHIFT, MapVirtualKey(VK_SHIFT, 0), 0, 0);
Sleep(250);
keybd_event(VK_END, MapVirtualKey(VK_END, 0), 0, 0);
Sleep(250);
keybd_event(VK_END, MapVirtualKey(VK_END, 0), KEYEVENTF_KEYUP, 0);
Sleep(250);
keybd_event(VK_SHIFT, MapVirtualKey(VK_SHIFT, 0), KEYEVENTF_KEYUP,
0);
Sleep(250);

Please note I've also tried:

VK_LSHIFT instead of VK_SHIFT, but doesn't work.

VK_RSHIFT instead of VK_SHIFT. The highlighting and text copying work,
but shift key stays pressed down afterward. I have to manually hit
right shift key to release it. I shouldn't have to do this.

Please provide any help if you know the solution.

Regards,

Roshan
 
V

Victor Bazarov

[...] Some combos work such as Shift key + h which gives 'H'. The problem
is [..] VK_RSHIFT instead of VK_SHIFT. [..]

Please provide any help if you know the solution.

Please post to 'comp.os.ms-windows.programmer.win32' where this is
on topic. Here it isn't.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top