如何模拟键盘输入 " q8888 " 加 回车键(100分)

  • 主题发起人 主题发起人 cloris2008
  • 开始时间 开始时间
C

cloris2008

Unregistered / Unconfirmed
GUEST, unregistred user!
我要模拟键盘向我的当前激活的DOS窗口程序中,输入 q8888 加回车键,请问有什么办法可能实现?
 
keybd_event($xx, 0, 0 , 0); // key down<br>keybd_event($xx, 0, KEYEVENTF_KEYUP , 0); // key up<br><br>$xx查一下ASCII码值。<br>
 
WriteConsoleInput<br>WriteConsoleOutput<br>查一下关于它的帮助,或许可以。
 
两位可以再详继一些吗? 有没有类似的原代码例子。 谢谢
 
procedure Tform1.keyevent(str:string);<br>var<br>&nbsp; &nbsp;i &nbsp; &nbsp; : integer;<br>&nbsp; &nbsp;c &nbsp; &nbsp; : byte;<br>begin<br>&nbsp; &nbsp; keybd_event(vk_Return,0,0,0);<br>&nbsp; &nbsp; keybd_event(vk_Return,0,KEYEVENTF_KEYUP,0);<br>&nbsp; &nbsp;for i := 1 to Length(str) do<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; c := VkKeyScan(str) and 255; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//输入文字<br>&nbsp; &nbsp; keybd_event(c,0,0,0);<br>&nbsp; &nbsp; keybd_event(c,0,KEYEVENTF_KEYUP,0);<br>&nbsp; &nbsp;end;<br>&nbsp; &nbsp; keybd_event(vk_Return,0,0,0); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//输入后回车<br>&nbsp; &nbsp; keybd_event(vk_Return,0,KEYEVENTF_KEYUP,0);<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>keyevent('q8888');<br>end;<br>
 
楼上说的办法很好用。俺一直用它。呵呵。
 
为何还不给分?<br>
 
谢谢,接受了[:)]<br><br>解决了
 
后退
顶部