如何实现这个功能:一段时间没有如何操作,关闭程序?
RT 问题点数:20、回复次数:2Top
1 楼aohan(aohan)回复于 2006-03-16 20:37:04 得分 10
比如可以记录光标的位置,在指定的时间段内如果光标没有动作,则触发相关过程
Public Type POINTAPI
X As Long
Y As Long
End Type
Public Declare Function GetCursorPos Lib "user32" (ByRef lpPoint As POINTAPI) As Long '读取鼠标位置
Dim Pmouse As POINTAPI '读取到的当前鼠标位置
GetCursorPos Pmouse
在变量中存取Pmouse 的位置,然后在指定的时间段内比较
Top
2 楼supergreenbean(超级绿豆(MSMVP - VB) - 升级归来~)回复于 2006-03-16 20:47:12 得分 10
Option Explicit
Private Declare Function GetLastInputInfo Lib "user32" (plii As LASTINPUTINFO) As Boolean
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Type LASTINPUTINFO
cbSize As Long
dwTime As Long
End Type
Private Sub Form_Load()
Timer1.Interval = 1
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Dim lii As LASTINPUTINFO
lii.cbSize = Len(lii)
If GetLastInputInfo(lii) Then
If (GetTickCount() - lii.dwTime) >= 10000 Then '空闲10秒(10000毫秒)就卸载窗体
Unload Me
End If
End If
End Sub
Top




