eXorcist Posted November 16, 2006 Share Posted November 16, 2006 Hello all, Sorry for my english... i need to write a script which detect the inactivity of Windows or of a specific program for x minutes. If it's true, i launch a fonction (to log off from this program but not close it). if not, i wait... i think a program like that : Start if inactive > 5 then log off program Z sleep 5 minutes else sleep 1 minute go to Start It will be more complicated but it's just to give you an idea of what i need. I write a program using Task Sheduler from Windows XP but it's not good for using i need. Thanks in advance for your help, eXo Link to comment Share on other sites More sharing options...
Helge Posted November 16, 2006 Share Posted November 16, 2006 Search all forums for topics with "idle" in the title and you'll get lots of similar topics as yours...http://www.autoitscript.com/forum/index.ph...ighlite=%2Bidle Link to comment Share on other sites More sharing options...
_Kurt Posted November 16, 2006 Share Posted November 16, 2006 Maybe this could help for the 5 minute of inactivity Run("notepad.exe") WinActivate("Untitled") Sleep(2000);Give Notepad time to become active While 1 If NOT WinActive("Untitled") Then Sleep(300000) If NOT WinActive("Untitled") Then ;Whatever you want Exit;This is an example EndIf EndIf WEnd Exit UNTESTED Made this really quick, might not work Kurt Awaiting Diablo III.. Link to comment Share on other sites More sharing options...
AzKay Posted November 16, 2006 Share Posted November 16, 2006 You could PixelCheckSum() the whole screen. Lol # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
eXorcist Posted November 16, 2006 Author Share Posted November 16, 2006 Thanks Kurt, But the window could be active.. but not used (no mouse event and no keyboard event...) So i think it's not solution but thanks Maybe this could help for the 5 minute of inactivity Run("notepad.exe") WinActivate("Untitled") Sleep(2000);Give Notepad time to become active While 1 If NOT WinActive("Untitled") Then Sleep(300000) If NOT WinActive("Untitled") Then ;Whatever you want Exit;This is an example EndIf EndIf WEnd Exit UNTESTED Made this really quick, might not work Kurt Link to comment Share on other sites More sharing options...
jvanegmond Posted November 16, 2006 Share Posted November 16, 2006 (edited) http://www.autoitscript.com/forum/index.php?showtopic=4361and here's my version that checks for a change in the size of a printscreen.$TimeToCallTheFunction = 5000 ; in milliseconds While 1 $LastSize = _GetExtProperty(@ScriptDir & "\dump.jpg") DllCall("captdll.dll", "int", "CaptureScreen", "str", "dump.jpg", "int", 50) If _GetExtProperty(@ScriptDir & "\dump.jpg") <> $LastSize Then $Timer = TimerInit() ElseIf TimerDiff($Timer) > $TimeToCallTheFunction Then TheFunction() EndIf Sleep(1000) WEnd Func TheFunction() MsgBox(0,@ScriptName,"The system has been idle for " & Int($TimeToCallTheFunction/1000) & " seconds.") EndFunc Func _GetExtProperty($s_path,$i_prop = 1) $s_file = StringTrimLeft($s_path,StringInStr($s_path,"\",0,-1)) $s_dir = StringTrimRight($s_path,(StringLen($s_path)-StringInStr($s_path,"\",0,-1))) $ShellApp = ObjCreate("shell.application") $oDir = $ShellApp.NameSpace($s_dir) $oFile = $oDir.Parsename($s_file) $property = $oDir.GetDetailsOf($oFile, $i_prop) If Not $property = "" Then Return $property EndIf EndFuncYou can get the DLL needed here Edited November 16, 2006 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now