mwr1203 Posted June 21, 2013 Share Posted June 21, 2013 I need a very simple script. I think. I work for an HVAC automation Company. We have several programs running on 1 PC at a particular customers site. They want one of these programs window to restore automatically after a certain amount of idle time like 2 minutes. Maintenance staff come and use other applications on the PC and forget to restore the program window that they would like displayed at all times. Can anyone help me with this Link to comment Share on other sites More sharing options...
jdelaney Posted June 21, 2013 Share Posted June 21, 2013 $sTitle = "Title of your App" $sExe = "Your Exe with path" While True If Not WinWaitActive($sTitle, "", 120) Then If Not WinExists($sTitle) Then Run ($sExe) WinSetState ($sTitle, "", @SW_RESTORE) WinSetState ($sTitle, "", @SW_MAXIMIZE) WinActivate ($sTitle) EndIf WEnd IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
mwr1203 Posted June 21, 2013 Author Share Posted June 21, 2013 That works great, but it works all the time even if I am working on something. The application window I want restores. I need it to only happen after the PC has been idle for 2 minutes. Link to comment Share on other sites More sharing options...
Andreu Posted June 21, 2013 Share Posted June 21, 2013 (edited) Just a slight variation to suit your last issue. Edit: Just want to point out, if your sitting back watching a video or something (or anything where you could leave the mouse idle for over 2 minutes), this will trigger your intended purpose. If this poses a problem, let me know. $sTitle = "Title of your App" $sExe = "Your Exe with path" While True $X = MouseGetPos(0) $Y = MouseGetPos(1) If Not WinWaitActive($sTitle, "", 120) Then If MouseGetPos(0) = $X And MouseGetPos(1) = $Y Then If Not WinExists($sTitle) Then Run ($sExe) WinSetState ($sTitle, "", @SW_RESTORE) WinSetState ($sTitle, "", @SW_MAXIMIZE) WinActivate ($sTitle) EndIf EndIf WEnd Edited June 21, 2013 by Andreu Link to comment Share on other sites More sharing options...
jdelaney Posted June 21, 2013 Share Posted June 21, 2013 (edited) here ya go #include <Timers.au3> $sTitle = "Title of your App" $sExe = "Your Exe with path" $iIdleTimeMilSec = 120000 While True If Not WinActive($sTitle) And _Timer_GetIdleTime()>$iIdleTimeMilSec Then If Not WinExists($sTitle) Then Run ($sExe) WinSetState ($sTitle, "", @SW_RESTORE) WinSetState ($sTitle, "", @SW_MAXIMIZE) WinActivate ($sTitle) EndIf WEnd Edited June 21, 2013 by jdelaney Andreu 1 IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. 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