Private Declare Function GetLastInputInfo Lib "user32" (plii As LASTINPUTINFO) As Boolean Private Type LASTINPUTINFO cbSize As Long dwTime As Long End Type Dim IOInfo As LASTINPUTINFO Dim LngBak As Long Dim LngCnt As Long Dim LngEnd As Long '停止时间,分钟 Private Sub Form_Load() LngEnd = 3 LngCnt = 0 Timer1.Interval = 1000 Timer1.Enabled = True End Sub ' Private Sub Timer1_Timer() IOInfo.cbSize = Len(IOInfo) Call GetLastInputInfo(IOInfo) If LngBak <> IOInfo.dwTime Then LngBak = IOInfo.dwTime LngCnt = 0 End If LngCnt = LngCnt + 1 If LngCnt = LngEnd Then Timer1.Enabled = False MsgBox "到时间了!",vbOKOnly,"Info" End If End Sub