var
key:byte;//ASCII码
btScancode:DWord; //键码
begin
key:=VkKeyScan('b');
btScancode:= MapVirtualKey(key, 0);
end; //winio模拟,大小写需要自己模拟shift键盘自己转化。 procedure KBCWait4IBE; //等待键盘缓冲区为空
var
dwVal:DWord;
begin
repeat
GetPortVal($64,@dwVal,1);
until (dwVal and $2)=0;
end; procedure MyKeyDown(vKeyCoad:Integer);
var
btScancode:DWord;
begin
btScancode:=MapVirtualKey(vKeyCoad, 0);
KBCWait4IBE;
SetPortVal($64, $D2, 1);
KBCWait4IBE;
SetPortVal($60, btScancode, 1);
end; procedure MyKeyUp(vKeyCoad:Integer);
var
btScancode:DWord;
begin
btScancode:=MapVirtualKey(vKeyCoad, 0);
KBCWait4IBE;
SetPortVal($64, $D2, 1);
KBCWait4IBE;
SetPortVal($60, (btScancode or $80), 1);
end; procedure TForm1.Timer1Timer(Sender: TObject);
var
i:Byte;
begin
MyKeyDown(VK_SHIFT);
MyKeyDown(VkKeyScan('b'));
Sleep(50);
MyKeyUp(VkKeyScan('b'));
MyKeyUp(VK_SHIFT);
end;
05-13 18:13