求模拟键盘鼠标后 如何禁止物理键鼠的方法
做了个 模拟 键盘 鼠标 的程序,可以控制SAP自动操作了 , 可是在运行的时候 鼠标 键盘 不能操作的 ,如果一不小心 一改变当前窗口 ,改变当前鼠标指针位置 就会发生错误 导致程序无法继续 。
想请教大家 有没有办法 屏蔽 物理的键盘 鼠标 , 将控制权完全交给 KEY EVENT , MOUSE EVENT ?
程序运行完毕再将控制权换回来? 谢谢
** API函数锁定键盘及鼠标 DECLARE LONG BlockInput IN User32 LONG DECLARE LONG keybd_event IN User32 LONG,LONG,LONG,LONG of = CREATEOBJECT("_Form") of.Show(1) DEFINE CLASS _Form AS Form AutoCenter = .T. nTime = DATETIME() ADD OBJECT Txt1 AS TextBox WITH Top=10,Left=10,Width=50 ADD OBJECT Cmd1 AS CommandButton WITH Top=10,Left=70,Width=50,Height=22,Caption="Lock" ADD OBJECT Timer1 as Timer WITH Interval=1000,Enabled=.F. PROCEDURE Cmd1.Click thisform.nTime = DATETIME() thisform.Caption = "Lock" thisform.Txt1.SetFocus BlockInput(1) thisform.Timer1.Enabled = .T. ENDPROC PROCEDURE Timer1.Timer IF (DATETIME() - thisform.nTime) > 10 thisform.Caption = "UnLock" thisform.Timer1.Enabled = .F. BlockInput(0) ELSE thisform.Caption = "Lock " + TRANSFORM(DATETIME() - thisform.nTime) keybd_event(ASC("A"),0,0,0) &&按下a键 keybd_event(ASC("A"),0,2,0) &&松开a键 ENDIF ENDPROC ENDDEFINE