Jump to content
careca

Problem in windows 10 "_Timer_GetIdleTime()"

Recommended Posts

careca
#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

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

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

GPO Tool - Export/Import Group policy settings.

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.

Firefox Profile Backup - Backup/restore previously saved profile.

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
VIP

I tried it on my computer and the results:

image.png

 


Regards,
 

Share this post


Link to post
Share on other sites
careca

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

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

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

GPO Tool - Export/Import Group policy settings.

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.

Firefox Profile Backup - Backup/restore previously saved profile.

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
VIP

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

Regards,
 

Share this post


Link to post
Share on other sites
orbs

@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
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?

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

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

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

GPO Tool - Export/Import Group policy settings.

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.

Firefox Profile Backup - Backup/restore previously saved profile.

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
careca

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

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

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

GPO Tool - Export/Import Group policy settings.

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.

Firefox Profile Backup - Backup/restore previously saved profile.

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
orbs

... 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!

  • Like 1

Share this post


Link to post
Share on other sites
careca

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

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

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

GPO Tool - Export/Import Group policy settings.

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.

Firefox Profile Backup - Backup/restore previously saved profile.

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
orbs

... 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
careca

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

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

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

GPO Tool - Export/Import Group policy settings.

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.

Firefox Profile Backup - Backup/restore previously saved profile.

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
Turranius

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
BrewManNH

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
careca

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

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

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

GPO Tool - Export/Import Group policy settings.

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.

Firefox Profile Backup - Backup/restore previously saved profile.

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
Turranius

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.

  • Like 1

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

    • Dreamfire
      By Dreamfire
      Hi,
      Since today, exe's are being flagged as having a trojan by Windows Defender (Fuery.B!cl)
      Version:  3.3.14.3 - SciTE Version 3.7.3



       

    • PramodR
      By PramodR
      Hello,
      I have to execute below block of code in elevated previllage, as that particular wmic class will work only with admin previlage.
      i am getting out put when i launch autoit as administrator,  but i will not be able to launch autoit as admin in this particular case but my user have admin rights.
      is there any better way i can run those command as administrator.?
      tried below steps:
      i have tried #RequireAdmin but that creates a user prompt  Tried using Runas command but gives error as wrong username or password , stuck with that step.  
       
    • dwaynek
      By dwaynek
      traytip isn't working in windows 10. nothing happens when i use the Traytip command.
      here's a simple script i used:
      TrayTip("I'm a title", "I'm the message", 5) i tried changing the registry setting HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced ( which didn't have EnableBalloonTips) and creating a DWORD entry called EnableBalloonTips and setting it to 1 and logging off then back in. that did not resolve the problem.
      i'm running Windows 10 v1709 b16299.431
    • antonioj84
      By antonioj84
      Hi all to the forum guru and expert I am trying to  automate this. in the registry  I have the network profile name network 2 and network   I want to  change their  CATEGORY  to Private .  Can someone lead me in the right direction.
      Private is 1 and Public is 0
      #RequireAdmin Global $sHKLMRoot = @OSArch = "x64" ? "HKLM64" : "HKLM" RegWrite($sHKLMRoot &"\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\NewNetworks" ,'/v NetworkList /t REG_MULTI_SZ /d 00000000 /f') see  attached picture below
      Much appreaciate
       

    • PhoenixPRO
      By PhoenixPRO
      When I try to automate this install program I can not get any of the buttons to click with the "ControlClick" function or any mouse movement to move the mouse to the and click it.  My OS is Windows 10 64Bit.  I have tried both 32bit and 64bit installs of Autoit V3 to no avail.
      I could not even get the run command to start the program until I used the variation of the command below in the script.
      With the script below the install program starts but will not click the "Next" button no matter what I do.
      Any help will be greatly appreciated.
      Thanks in advance.
       
      #include <MsgBoxConstants.au3>
      Opt("MouseCoordMode", 0) ;1=absolute, 0=relative to active window, 2=client
      Local $Success
      Run(@ComSpec & " /c " & 'C:\PhoenixPro_Install\RDXUtil\RDX_Tools_setup.exe', "C:\PhoenixPro_Install\RDXUtil", @SW_HIDE )

      WinWait("RDX Tools 1.62 - InstallShield Wizard", "Welcome to the InstallShield Wizard for RDX Tools 1.62")
      WinActivate("RDX Tools 1.62 - InstallShield Wizard", "Welcome to the InstallShield Wizard for RDX Tools 1.62")
      ControlClick ("RDX Tools 1.62 - InstallShield Wizard", "Welcome to the InstallShield Wizard for RDX Tools 1.62", 1639, "left", 1) ;Next Button
×