Jump to content
careca

Problem in windows 10 "_Timer_GetIdleTime()"

Recommended Posts

#include <Timers.au3>

While 1
Local $iIdleTime = _Timer_GetIdleTime()
ConsoleWrite($iIdleTime &' - '&@MSEC&@CRLF)
Sleep(150)
WEnd

Hi all, This used to work well in Win7, now in Win10 it auto resets constantly without any input, any ideas?


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites

I tried it on my computer and the results:

I see, here's what happens here:

So what do you suggest?

 

 

Capture.PNG

Edited by careca
Screenshot

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites

Results from the test showed script runs very good.

If I do not move the mouse or press any key (inactive)
it will start counting IdleTime.

If any activity, IdleTime will be reset.
And will continue counting when the computer inactive!

;#include <Timers.au3>

While 1
    Local $iIdleTime = _Timer_GetIdleTime()
    ConsoleWrite($iIdleTime & ' - ' & @MSEC & @CRLF)
    Sleep(150)
WEnd

Func _Timer_GetIdleTime()
    ; Get ticks at last activity
    Local $tStruct = DllStructCreate("uint;dword");
    DllStructSetData($tStruct, 1, DllStructGetSize($tStruct));
    Local $aResult = DllCall("user32.dll", "bool", "GetLastInputInfo", "struct*", $tStruct)
    If @error Or $aResult[0] = 0 Then Return SetError(@error, @extended, 0)

    ; Get current ticks since last restart
    Local $avTicks = DllCall("kernel32.dll", "dword", "GetTickCount")
    If @error Or Not $aResult[0] Then Return SetError(@error, @extended, 0)

    ; Return time since last activity, in ticks (approx milliseconds)
    Local $iDiff = $avTicks[0] - DllStructGetData($tStruct, 2)
    If $iDiff < 0 Then Return SetExtended(1, $avTicks[0]) ; Rollover of ticks counter has occured
    ; Normal return
    Return $iDiff
EndFunc   ;==>_Timer_GetIdleTime

 

Edited by Trong

Share this post


Link to post
Share on other sites

@careca,

first, redeclaring Local inside a loop hurts my very few left brain cells. please stop it.

now, even if you do not touch your mouse or keyboard, something else obviously does - but it does not have to be human. i once noticed that same issue with an nVidia driver which needed to be updated, and in another occasion i overheard that a laptop touchpad driver was to blame.

i just searched my mail, but i can't seem to find the related info. if i do, perhaps i can get some more details for you. meanwhile, follow a standard troubleshooting procedure: test in safe mode, if that works then start disabling drivers, services, apps and stuff, until you find the culprit.

also: is it a physical or virtual machine running Windows 10?

Share this post


Link to post
Share on other sites

first, redeclaring Local inside a loop hurts my very few left brain cells. please stop it.

now, even if you do not touch your mouse or keyboard, something else obviously does - but it does not have to be human. i once noticed that same issue with an nVidia driver which needed to be updated, and in another occasion i overheard that a laptop touchpad driver was to blame.

i just searched my mail, but i can't seem to find the related info. if i do, perhaps i can get some more details for you. meanwhile, follow a standard troubleshooting procedure: test in safe mode, if that works then start disabling drivers, services, apps and stuff, until you find the culprit.

also: is it a physical or virtual machine running Windows 10?

Hi, i never redeclare inside a loop, it's just that i copy-pasted from the example and then put a loop around it, don't worry, i never do it unless for these test examples.

Ok, i'll test safe mode.

It's a physical machine, without touchpad, meaning desktop, but does the same in my laptop...


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites

Results from the test showed script runs very good.

Well, it doesn't here, as i said before, and i understand how it works, just need to find what is reseting it. ;)


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites

... it's just that i copy-pasted from the example ...

as my professor used to say, "even copying is something one must know how to do correctly" ;)

now, assuming GetLastInputInfo or GetTickCount are being messed with, and if you want a reliable functionality over multiple systems, perhaps a different approach is in order - depending on your actual purpose. if you are comfortable with "idle time" being redefined as "the time since last mouse move" (ignoring keyboard input), then the script hereunder demonstrates how it can be applied:

AdlibRegister('_MouseIdleTime')

HotKeySet('{ESC}', '_Exit')

While True
    ConsoleWrite(_MouseIdleTime() & @CRLF)
    Sleep(100)
WEnd

Func _Exit()
    Exit
EndFunc   ;==>_Exit

Func _MouseIdleTime()
    Local Static $hTimer ; a running timer measuring the required idle time
    Local Static $aMousePosOld[2] ; holding the previous mouse position, to be compared to current mouse position
    Local $aMousePosNew = MouseGetPos() ; get current mouse position for comparison
    If $aMousePosOld[0] <> $aMousePosNew[0] Or $aMousePosOld[1] <> $aMousePosNew[1] Then ; mouse has moved
        ; remember new pos
        $aMousePosOld[0] = $aMousePosNew[0]
        $aMousePosOld[1] = $aMousePosNew[1]
        ; zero timer
        $hTimer = TimerInit()
        ; return zero, which indicates a mouse move to the calling script
        Return 0
    Else ; mouse has not moved
        Return TimerDiff($hTimer) ; let the calling script know for how long
    EndIf
EndFunc   ;==>_MouseIdleTime

important: this script does not consider keyboard input, as well as any other input device which does not simulate a mouse cursor!

Share this post


Link to post
Share on other sites

Yeah, i was thinking about that, it will work, thanks, it's for a code that turns the monitor off with a hotkey when im going away.

PS: I'll probably add some more lines to that, in order to detect space and enter to wake up.

Thanks everyone!

 

EDIT: So i discovered that DWM.exe or 'Desktop Windows Manager' was the culprit, had to kill explorer first, and as soon as i killed DWM the count started to climb. So now that i know that, do you think there's a way to ignore that process?

Edited by careca
Found out

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites

... it's for a code that turns the monitor off with a hotkey when im going away.

isn't that a built-in "Power Options" feature? set it to turn the monitor off after 1 minute and you'll be fine.

EDIT: So i discovered that DWM.exe or 'Desktop Windows Manager' was the culprit, had to kill explorer first, and as soon as i killed DWM the count started to climb. So now that i know that, do you think there's a way to ignore that process?

DWM by itself is, in all likelihood, innocent. DWM is responsible for integrating Windows (the OS) effect and windows (of programs) graphics to a composite image which is then displayed on screen (here is a pretty decent article about it). you really should investigate further on to which is the app that - when its graphics is processed by DWM - creates the issue.

Share this post


Link to post
Share on other sites

isn't that a built-in "Power Options" feature? set it to turn the monitor off after 1 minute and you'll be fine.

DWM by itself is, in all likelihood, innocent. DWM is responsible for integrating Windows (the OS) effect and windows (of programs) graphics to a composite image which is then displayed on screen (here is a pretty decent article about it). you really should investigate further on to which is the app that - when its graphics is processed by DWM - creates the issue.

I want to decide when to shut it off.

If DWM is not the one, how can i find what is?, i literally killed every process and that was the only one that did the trick.


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites

I am seeing the same problem with a BlissBox (USB hub that works with almost all old retro game controllers).

 

As soon as I plug that in, the timer never goes above 16ms, even with no joysticks plugged into it. As soon as I unplug it, the idle timer starts rising.

Not that I expect any help with that from this forum, I just thought it is worth nothing for the future if anyone else have any problem. I've yet to find a solution for it.

#include <Timers.au3>

HotKeySet("+{ESC}", "_Quit")

While 1
   SplashTextOn("Test of idle timer. Shift-Esc to quit.", "This timer should go up if you do not touch anything." & @CRLF & @CRLF & _Timer_GetIdleTime(),-1,100)
   Sleep(1000)
WEnd

Func _Quit()
   SplashOff()
   Exit
EndFunc

 

Edited by Turranius

Share this post


Link to post
Share on other sites

Sounds like the hub does this on purpose to prevent the screensaver/sleep from kicking in. It's probably because the controllers aren't seen as keyboard or mouse input so the screensaver might come on if it didn't do that, but that's just a guess.


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

Share this post


Link to post
Share on other sites

I ended up discovering that for me, it was a controller/gamepad, that was connected in those ports i never touch in the back..


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites

To follow up on this...

 

If you are using the release version of Windows 10 (10240?), the _Timer_GetIdleTime() is indeed reset when using a Game Controller. Microsoft considers this a bug, so...

In the big november update (1511), they fixed this so Game Controllers no longer reset the _Timer_GetIdleTime() (And your screensaver goes on if you are only using a game controller...).

 

So the reason for my problems was because the BlissBox was sending out a signal every 16ms. With the release version of Windows 10, this reset the _Timer_GetIdleTime() every 16ms. I've updated to Windows 10 version 1511 and the problem is gone.

 

Of course, now _Timer_GetIdleTime() is pretty useless if you are sitting with a game controller only, but that is not Autoits fault but a design decision from Microsoft.

Share this post


Link to post
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

  • Similar Content

    • By gahhon
      I have a application that have a function is to create a shortcut to desktop, lets say is ChromePortable.lnk.
      $iCreate = FileCreateShortcut($DIR_WA_FOLDER & '\GoogleChromePortable.exe', $DIR_SHORTCUT, $DIR_WA_FOLDER, '--kiosk "https://example.com/"') So the shortcut will be launch as kiosk mode and force to enter the specific website. However, the user is still able to right-click on the shortcut and modify the target value to remove the kiosk mode. What can I do to disable the user to editing the target value?
      So far, I had asked and tried from SuperUser for advises Disable Shortcut Target Field
      icacls "ChromePortable.lnk" /GRANT EVERYONE:RX So this will set the permission of this shortcut file to only Read & Execute only! But after I set it, the user is still can modify.
      Please kindly advise.
      Please note and assume that user don't have Administration account or etc, that should be only have 1 account to logon to the computer.
       
      EDIT:
      I must disable inheritance to remove all others permissions like SYSTEM, ADMINISTRATORS, etc. Then only GRANT everyone for READ & EXECUTE only.
      But still the user can go to edit the permissions tho. Any advise?
    • By ur
      When I compiled my script or any script to exe using 32 bit compiler and ran on 32 bit machine, I am getting below error.
       

       
      But it is 32 bit only.
       
      And, for testing, I disabled smart screen also, but same issue.
      Please suggest.
       
    • By sadakathullah
      Hi All, I am new to AutoIT and exploring options to use it in my organization. I tried couple of examples and it is fantastic. I am trying to run restrictions test in a pc to see if certain options are disabled like print screen, mstsc etc. I could not get a hang of it. Any help is much appreciated.
    • By stayready40
      Hello all. I created a script to uninstall Symantec from our environment and I placed the "BlockInput(1)" command in the beginning of the script so that end users would not be able to move the mouse or keyboard to disrupt the mouse clicks.
      During testing we found that this worked for our Windows 7 machines, but for our windows 10 machines the mouse disable did not work can anyone shed some light on why this is? 
      Here is my code:

       
    • By faustf
      hi guys
      i have a script  like this,  in windows 7 work perfect , in windows 10 not  work  , some one can explain me  why ??'
      #include <Array.au3> #include <MsgBoxConstants.au3> Global $aGPathFoto= FileReadToArray (@ScriptDir & "\TEMP\PathFoto.txt") Local $ctrl = 0 While 1 Local $hWnd = WinWait("[CLASS:#32770]", "", 10) If WinExists("[CLASS:#32770]") Then If $ctrl < 2 Then ControlSend($hWnd, "Choose File to Upload", "[CLASS:Edit; INSTANCE:1]", $aGPathFoto[0]&"{Enter}") Exit $ctrl += 1 Else ExitLoop EndIf EndIf WEnd $aGpathfoto = C:\Users\Public\Pictures\Sample Pictures\Chrysanthemum.jpg
×
×
  • Create New...