Jump to content

Help!


Recommended Posts

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

$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

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
Link to comment
Share on other sites

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.
Link to comment
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
 Share

  • Recently Browsing   0 members

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