为什么这段程序不能正常模拟按键???急求解答!(15分)

  • 主题发起人 主题发起人 16cy
  • 开始时间 开始时间
1

16cy

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure mylogin(user:string;password:string);<br>var<br>u,p:integer;<br>i:Byte;<br>begin<br>u:=length(user);<br>p:=length(password);<br>for u := 1 to u &nbsp;do<br> &nbsp;begin<br> &nbsp; &nbsp;i:=byte(user);<br> &nbsp; &nbsp;keybd_event(i,mapvirtualkey(i,0),0,0);<br> &nbsp; &nbsp;keybd_event(i,mapvirtualkey(i,0),keyeventf_keyup,0);<br> &nbsp; &nbsp;sleep(50);<br> &nbsp;end;<br>end;<br><br>这段程序不能正常按键,mapvirtualkey(i,0)的硬件扫描码老是出错,可是我把i用具体的数字代替又可以正常按键。如:<br>procedure mylogin(user:string;password:string);<br>var<br>u,p:integer;<br>i:Byte;<br>begin<br>u:=length(user);<br>p:=length(password);<br>for u := 1 to u &nbsp;do<br> &nbsp;begin<br> &nbsp; &nbsp;keybd_event(u,mapvirtualkey(u,0),0,0);<br> &nbsp; &nbsp;sleep(10);<br> &nbsp; &nbsp;keybd_event(u,mapvirtualkey(u,0),keyeventf_keyup,0);<br> &nbsp; &nbsp;sleep(50);<br> &nbsp;end;<br>end;<br>这段程序又是正常的,我晕,有高手吗,帮我分析一下,在线等。
 
for u := 1 to u &nbsp;do????
 
笔误<br>改成下面的代码,还是不行。<br>procedure mylogin(user:string;password:string);<br>var<br>u,p,j:integer;<br>i:Byte;<br>begin<br>u:=length(user);<br>p:=length(password);<br>for j := 1 to u &nbsp;do<br> &nbsp;begin<br> &nbsp; &nbsp;i:=byte(user[j]);<br> &nbsp; &nbsp;keybd_event(i,mapvirtualkey(i,0),0,0);<br> &nbsp; &nbsp;keybd_event(i,mapvirtualkey(i,0),keyeventf_keyup,0);<br> &nbsp; &nbsp;sleep(50);<br> &nbsp;end;<br>end;
 
接受答案了.
 
后退
顶部