It sounds like your requirements have changed a bit... and that is fine.
Below is one way to do what you originally asked about doing:
Code:
AutoItSetOption ("TrayIconDebug", 1)
;prevents multiple copies of the script from running
$S_running = "idle-timer-test" ;name the script
If WinExists($S_running) Then Exit
AutoItWinSetTitle($S_running)
;you can remark this out too - you always want the script to run
HotKeySet("+{ESC}", "_end_this") ; press Ctrl-ESC to end script
#include <Timers.au3>
#include <File.au3>
;delete the file if it happens to be there
FileDelete(@MyDocumentsDir & "\idle-time.txt")
While 1
Local $iIdleTime = _Timer_GetIdleTime()
;the tray tip is just for debugging - it can be remarked out
TrayTip('press Shift+ESC to end script', "been idle for about " & $iIdleTime & "ms", 100)
Sleep(1000)
If $iIdleTime > (1000 * 60) Then ;add another times 60 to make it one hour
_FileCreate(@MyDocumentsDir & "\idle-time.txt")
Do
;the tray tip is just for debugging - it can be remarked out
TrayTip('press Shift+ESC to end script', "waiting for idle-time.txt to be deleted", 100)
Sleep(1000)
Until Not FileExists(@MyDocumentsDir & "\idle-time.txt")
EndIf
WEnd
Func _end_this()
Exit
EndFunc
Below is the batch file to be called by unlocking the computer:
Code:
if exist "C:\Users\username\Documents\idle-time.txt" notepad.exe
del "C:\Users\username\Documents\idle-time.txt"
pause
pause can be removed once it works
Maybe you can glean something from the code above.
Below the second video in
this post is some info about AutoIt that you might want to keep in mind.