Jump to content

_Timer_GetIdleTime issue


Carlo84
 Share

Go to solution Solved by BrewManNH,

Recommended Posts

Hello i needed a function to detect userinput

1st i tried using:

 GUIRegisterMsg($WM_KEYDOWN, "_Exit")
 ($WM_KEYUP, "_Exit")
GUIRegisterMsg($WM_MOUSEMOVE, "_Exit")
But that doesnt work once there are controls on the GUI

 

so i came to find _Timer_GetIdleTime()

 

but the issue here is that after user activity it does the following:

1. it resets to zero (as it should)

2. it starts counting again (as it should)

3. at 5000 it resets. (theres my issue)

4. it counts again without resetting at 5000

 

why does it reset a second time without user activity?

 

example to recreate the problem:

#include <Timers.au3>
#include <GUIConstantsEx.au3>

GUICreate('_Timer_GetIdleTime', 512, 256)
GUISetState(@SW_SHOW)
$hLabel = GUICtrlCreateLabel('', 10, 10, 256, 25)
$iTime = _Timer_GetIdleTime()
While 1
    $iMsg = GUIGetMsg()
    If $iMsg = $GUI_EVENT_CLOSE Then Exit

    $iTime = _Timer_GetIdleTime()
    $iExtended = @extended
    GUICtrlSetData($hLabel, $iTime & '   ' & $iExtended)
WEnd
Have searched the forums but haven't been able to find anyone with the same specific issue. Edited by Djarlo
Link to comment
Share on other sites

  • Solution

It works fine for me. I let it run, it counts up. I move the mouse it resets. I stop moving the mouse and it counts up, it never stops at 5000 and resets for me. It might have something to do with the information in the remarks section on this page.

 

The tick count when the last input event was received (see LASTINPUTINFO) is not guaranteed to be incremental. In some cases, the value might be less than the tick count of a prior event. For example, this can be caused by a timing gap between the raw input thread and the desktop thread or an event raised by SendInput, which supplies its own tick count.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

It works fine for me. I let it run, it counts up. I move the mouse it resets. I stop moving the mouse and it counts up, it never stops at 5000 and resets for me. It might have something to do with the information in the remarks section on this page.

Thanks, should have looked it up on msdn indeed, helpfile doesn't have this part.

And checking for each key is more code then it's worth, i think ill just settle on monitoring mouse movement it's simplest and seems the most reliable method.

Link to comment
Share on other sites

I found the information by looking at what the function does internally. Looking at the DLLCall statement and searching for the function that is used in the DLL to get the information.

Local $aResult = DllCall("user32.dll", "bool", "GetLastInputInfo", "struct*", $tStruct)

So, looking at that line, I googled "GetLastInputInfo" and started to look at what was returned from MSDN. Most of the time when reading the MSDN pages I get horribly lost as to what the function does, but once in a while I can get something from them. :)

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...