Jump to content

Recommended Posts

Posted

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

Posted

$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.
Posted

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.

Posted (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 by Andreu
Posted (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 by jdelaney
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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...