转摘:鼠标N秒内没操作时执行一个动作!
* 转摘:十豆三 http://blog.*--可以应用到公开查询系统等
*--表单的Load事件加代码:
Public gnMouseX,gnMouseY,gnTotalTimer
Store 0 To gnMouseX,gnMouseY,gnTotalTimer
Declare Integer GetCursorPos In user32 String@ lpPoint
*--表单的Unload事件加代码:
Clear Dlls "GetCursorPos"
*--向表单添加一个Timer控件,Timer1控件的Interval值为1000(即1秒),Enabled属性为.T.,此控件的Timer事件:
cbuff=Space(16)
MyMouse=GetCursorPos(@cBuff) &&获取鼠标的坐标值
X=Asc(Substr(cBuff,2,1))*256+Asc(Substr(cBuff,1,1))
Y=Asc(Substr(cBuff,6,1))*256+Asc(Substr(cBuff,5,1))
If gnTotalTimer=10 &&10秒
Store 0 To gnMouseX,gnMouseY,gnTotalTimer
Messagebox('鼠标已经10秒没有移动了'+Space(5),64,'信息提示')
Else
If gnMouseX!=X Or gnMouseY!=Y
gnMouseX=Asc(Substr(cBuff,2,1))*256+Asc(Substr(cBuff,1,1))
gnMouseY=Asc(Substr(cBuff,6,1))*256+Asc(Substr(cBuff,5,1))
gnTotalTimer=0
Else
gnTotalTimer=gnTotalTimer+1
Endif
Endif
*--表单的Init事件加代码:
This.Timer1.Timer()
* 在上面的基础上,加入键盘无动作
* 表单的 KeyPress 事件即可(表单的 KeyPreview 设为.T.)
Store 0 To gnMouseX,gnMouseY,gnTotalTimer