Detekce aktivity myÜi nebo klßvesnice

Postup:
Option Explicit

Private Type POINTAPI
   x As Integer
   y As Integer
End Type

Private Declare Sub GetCursorPos Lib "user32.dll" _
   (lpPoint As POINTAPI)
Private Declare Function GetAsyncKeyState Lib "user32.dll" _
   (ByVal vKey As Long) As Integer

Private posOld As POINTAPI
Private posNew As POINTAPI

Public Function InputCheck() As Boolean

   Dim i As Integer

   'ZjiÜt∞nφ aktußlnφch koordinßt∙ pozice kurzoru myÜi
   Call GetCursorPos(posNew)

   'Porovnßnφ s p∙vodnφmi koordinßty
   If ((posNew.x <> posOld.x) Or (posNew.y <> posOld.y)) Then
      posOld = posNew
      InputCheck = True
      Exit Function
   End If

   'Test stisknutφ klßvesnice - stav klßves
   For i = 0 To 255
      If (GetAsyncKeyState(i) And &H8001) <> 0 Then
         InputCheck = True
         Exit Function
      End If
   Next i

   InputCheck = False

End Function

P°φklad pou₧itφ:
Private Sub Timer1_Timer()

   Label1.Caption = InputCheck

End Sub

Zp∞t

Autor: The Bozena