[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Hot to usa keybd_event ?

Posted on 1999-01-10
5
Medium Priority
?
420 Views
Last Modified: 2013-12-03
I have a problem with keybd_event.

I have Swedish keyboard and I want to use keybd_event to send "a" and "A" and how to send #!%&/()?;:,.-'* and send F1,F2,F3 and so on. Please help me.

/Fredrik
0
Comment
Question by:freddeN
  • 3
  • 2
5 Comments
 
LVL 4

Expert Comment

by:nil_dib
ID: 1418416
First you should map the virtualkey code in the scan code
using MapVirtualKey.
Then you can call keybd_event with the return value from MapVirtualKey.
For example this code calls the "Start menu" in Windows(Ctrl-Esc):
//scan code for Ctrl
unsigned      nCodeCtrl = MapVirtualKey(VK_CONTROL, 2);
//scan code for Esc
unsigned      nCodeEsc = MapVirtualKey(VK_ESCAPE, 2);

// Ctrl key down
keybd_event( VK_CONTROL, nCodeCtrl, 0,0      );
// Esc key down
keybd_event( VK_ESCAPE, nCodeEsc, 0,0      );
// Esc key up
keybd_event( VK_ESCAPE, nCodeEsc, KEYEVENTF_KEYUP,0      );
// Ctrl key up
keybd_event( VK_CONTROL, nCodeCtrl, KEYEVENTF_KEYUP,0      );
 
0
 
LVL 4

Accepted Solution

by:
nil_dib earned 30 total points
ID: 1418417
Opps .. want to answer ..
So for sending an "A" :
unsigned      nCodeA = MapVirtualKey(0x41, 2); // 0x41 = 'A'

keybd_event( 0x41, nCodeA, 0,0      );
keybd_event( 0x41, nCodeA, KEYEVENTF_KEYUP,0      );

for F1, F2... use VK_F1, VK_F2 ...

0
 

Author Comment

by:freddeN
ID: 1418418
Thanks..

But I have one last question that I hope you can answer.
Hot to use keybd_event and send characters like %&/()=?`! and also use Num Lock and the keys on that part of the keyboard.

/Fredrik
0
 
LVL 4

Expert Comment

by:nil_dib
ID: 1418419
You can use those characters directly ...

unsigned      nCode = MapVirtualKey('%', 2);
keybd_event( '%', nCode ....
0
 

Author Comment

by:freddeN
ID: 1418420
ok I will try..

Thanks for all help.

/Fredrik


0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question