码迷,mamicode.com
首页 > Windows程序 > 详细

delphi winio 输入

时间:2014-11-14 10:27:38      阅读:337      评论:0      收藏:0      [点我收藏+]

标签:io   ar   for   ad   as   c   text   class   ca   

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;

delphi winio 输入

标签:io   ar   for   ad   as   c   text   class   ca   

原文地址:http://www.cnblogs.com/honeynm/p/4096501.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!