Solved

Hot to usa keybd_event ?

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need example 5 128
Messagebox for a Web Site Application 4 81
Is COM supported from Apache 1 74
Dialogbox API leak? 18 109
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.…
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…

762 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