Solved

Hot to usa keybd_event ?

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now