?
Solved

Hot to usa keybd_event ?

Posted on 1999-01-10
5
Medium Priority
?
396 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

777 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