例子已发到你邮箱
procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key=48 then
showmessage(IntToStr(key));
if Key=49 then
showmessage(IntToStr(key));
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
keybd_event(48,0,0,0);
keybd_event(48,0,KEYEVENTF_KEYUP,0);
end;
procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
keybd_event(49,0,0,0);
keybd_event(49,0,KEYEVENTF_KEYUP,0);
end;