Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


ID: 22254, List all the virtual key codes

by ACS India Pvt. Ltd Senior Programmer Email: snehanshu.ashar@acs-inc.com


This code snippet describes how to list all the virtual key codes and use them to simulate keyboard events.
Download Details
FTP  download also available 0 bytes
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 3.0  to 8.0 3 downloads
Copyright: No significant restrictions


Size: 0 bytes
Updated on Fri, 27 Aug 2004 22:28:15 GMT
Originally uploaded on Fri, 27 Aug 2004 22:22:03 GMT
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;

For more information, see www.acs-inc.com

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Could not retrieve comments. Please try again later.

Server Response from: ETNACDC04