怎样监测表单中一定明间内有无鼠标键盘动作
怎样监测表单中一定明间内有无鼠标键盘动作
当鼠标N秒内无操作时执行一个操作(如:执行屏保、返回首页等)
http://blog.
键盘检测,表单的 KeyPress 事件即可(表单的 KeyPreview 设为.T.)
DECLARE LONG GetLastInputInfo IN User32 STRING@ oForm = CREATEOBJECT("Form1") oForm.Show(1) READ EVENTS RELEASE ALL CLEAR DLLS RETURN DEFINE CLASS Form1 As Form nLastInputTime = 0 nLastTime = 0 ADD OBJECT Timer1 AS Timer WITH Interval=1000 ADD OBJECT Text1 AS TextBox WITH Top=100,Left=120,Value=0 PROCEDURE UnLoad CLEAR EVENTS ENDPROC PROCEDURE Timer1.Timer IF INT(thisform._GetLastInputInfo()/1000) == thisform.nLastInputTime IF (INT(SECONDS()) - thisform.nLastTime) > 10 MESSAGEBOX("鼠标键盘无动作超过10秒关闭退出") thisform.Release ELSE thisform.Text1.Value = thisform.Text1.Value + 1 ENDIF ELSE thisform.nLastInputTime = INT(thisform._GetLastInputInfo()/1000) thisform.nLastTime = INT(SECONDS()) thisform.Text1.Value = 0 ENDIF ENDPROC FUNCTION _GetLastInputInfo LOCAL stLII stLII = 0h0800000000000000 GetLastInputInfo(@stLII) RETURN CTOBIN(RIGHT(stLII, 4), "4RS") ENDFUNC ENDDEFINE