#AdditionalJar: jna-5.8.0
#AdditionalJar: jna-platform-5.8.0
Sub Process_Globals
End Sub
Sub AppStart (Args() As String)
Test
StartMessageLoop
End Sub
Sub Test
For i = 1 To 10
Log(GetIdleTime)
Sleep(1000)
Next
End Sub
'Returns the idle time in milliseconds.
Sub GetIdleTime As Int
Dim LASTINPUTINFO As JavaObject
LASTINPUTINFO .InitializeNewInstance("com.sun.jna.platform.win32.WinUser.LASTINPUTINFO", Null)
Dim User32 As JavaObject
User32 = User32.InitializeStatic("com.sun.jna.platform.win32.User32").GetField("INSTANCE")
User32.RunMethod("GetLastInputInfo", Array(LASTINPUTINFO ))
Dim Kernel32 As JavaObject
Kernel32 = Kernel32.InitializeStatic("com.sun.jna.platform.win32.Kernel32").GetField("INSTANCE")
Dim CurrentTicks As Int = Kernel32.RunMethod("GetTickCount", Null)
Dim LastInput As Int = LASTINPUTINFO.GetField("dwTime")
Dim delta As Int = CurrentTicks - LastInput
Return delta
End Sub