Solved

Hot to usa keybd_event ?

Posted on 1999-01-10
5
369 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 10 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

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 …
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
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…

773 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