unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
procedure PostKeyEx32(key: Word;
const shift: TShiftState; specialkey: Boolean);
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
procedure PostKeyEx32(key: Word;
const shift: TShiftState; specialkey: Boolean);
type
TShiftKeyInfo =
record
shift: Byte;
vkey: Byte;
end;
byteset =
set of 0..7;
const
shiftkeys:
array [1..3]
of TShiftKeyInfo =
((shift: Ord(ssCtrl); vkey: VK_CONTROL),
(shift: Ord(ssShift); vkey: VK_SHIFT),
(shift: Ord(ssAlt); vkey: VK_MENU));
var
flag: DWORD;
bShift: ByteSet
absolute shift;
i: Integer;
begin
for i := 1
to 3
do
begin
if shiftkeys[i].shift
in bShift
then
keybd_event(shiftkeys[i].vkey, MapVirtualKey(shiftkeys[i].vkey, 0), 0, 0);
end;
{ For }
if specialkey
then
flag := KEYEVENTF_EXTENDEDKEY
else
flag := 0;
keybd_event(key, MapvirtualKey(key, 0), flag, 0);
flag := flag
or KEYEVENTF_KEYUP;
keybd_event(key, MapvirtualKey(key, 0), flag, 0);
for i := 3
downto 1
do
begin
if shiftkeys[i].shift
in bShift
then
keybd_event(shiftkeys[i].vkey, MapVirtualKey(shiftkeys[i].vkey, 0),
KEYEVENTF_KEYUP, 0);
end;
end;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
PostKeyEx32(Ord('
D'), [], False);
end;
end.