RT

解决方案 »

  1.   

    比如可以记录光标的位置,在指定的时间段内如果光标没有动作,则触发相关过程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 的位置,然后在指定的时间段内比较
      

  2.   

    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 TypePrivate Sub Form_Load()
        Timer1.Interval = 1
        Timer1.Enabled = True
    End SubPrivate 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