Google
 

Monday, August 30, 2004

List all the virtual key codes

This code snippet describes how to list all the virtual key codes and use them to simulate keyboard events. (email: snehanshu.ashar@acs-inc.com)

Description: Here, on formcreate, the combobox is built up with all key names using the GetKeyNameText function. I have added the virtual key code in the combo text. Then on combobox's change, you can simulate your Keybd_Event.

procedure TForm1.FormCreate(Sender: TObject);
var
i, j: Word;
MyKey: LPARAM; //Just to be brave!
TmpStr: array[0..100] of char;
begin
ComboBox1.Items.Clear;
ComboBox1.Text := '';
for i := 0 to 255 do
begin
MyKey := MapVirtualKey(i, 0); //if this is not done, we get
//actual keyboard scan code
MyKey := MyKey shl 16; //We need to shift it to left because the
// GetKeyNameText function expects it that way!
j := GetKeyNameText(MyKey, @TmpStr, 101);
if j > 0 then
begin
ComboBox1.Items.Add(string(TmpStr) + Format(' %.3d', [i]));
end;
end;
end;

procedure TForm1.ComboBox1Change(Sender: TObject);
var
VKey: Word;
begin
VKey := StrToInt(Copy(ComboBox1.Text, length(ComboBox1.Text) - 1, 3));
Edit1.SetFocus;
Keybd_Event(VKey, 0, 0, 0);
end;

7 comments:

Reliable One Staffing Services said...

Astonshing blog. I relished in the site and you
know I will be going to it again! Surfing the internet
hepls me to find blogs that arfe just as good.
Jump into my pharmacy staffing
blog.

Reliable One Staffing Services said...

Hype blog. And I admire your site and plan on
returning to it! When I web surf it always helps me to
find great blogs.
My temporary staffing
blog, is something you need to peep out!

Reliable One Staffing Services said...

Striking blog. I liked the site I will be back
again! Websurfing is a good way to find blogs like
yours.
Please come by and see my pharmacy employement
blog.

job opportunitya said...

Extraordinary blog. Your site was hip and fresh
and we'll visit it again! I love surfing the internet
for blogs.
I want you to stop and compare with my charlotte plastic surgery blog.

job opportunitya said...

Charming blog. Your site was off the chain and I
will return! When I get the time I look for blog like
this one.
Search for my plastic surgery thailand blog, please!

dhd said...

Youth is warcraft leveling not a time of life;warcraft leveling it is a wow lvl state of mind; wow power level it is not power leveling amatter of World of warcraft Power Leveling rosy cheeks, red wrath of the lich king power leveling lips and supple knees;WOTLK Power Leveling it is a matter of thewill,wlk Power Leveling a quality of buy aoc gold the imagination,aoc gold a vigor of the emotions; it is thefreshness of the deep springs of life. Youth means a tempera-mental maplestory mesos predominance of courage over timidity, of the appetite formaple story mesos adventure over the love of ease. This often existsin a man of 60 more than a boy of 20. Nobody grows old merely by anumber of years.

Adi said...

Oes Tsetnoc one of the ways in which we can learn seo besides Mengembalikan Jati Diri Bangsa. By participating in the Oes Tsetnoc or Mengembalikan Jati Diri Bangsa we can improve our seo skills. To find more information about Oest Tsetnoc please visit my Oes Tsetnoc pages. And to find more information about Mengembalikan Jati Diri Bangsa please visit my Mengembalikan Jati Diri Bangsa pages. Thank you So much.