Sign in to follow this  
Followers 0
grimmlock

Script to close an app

8 posts in this topic

Here is the code I am working with

#include <Timers.au3>

;Declare the Timer:
Global $TIMER = TimerInit()


While 1

;If this application is active then reset the timer:
If WinActive("iexplorer.exe") Then
$TIMER = TimerInit()
EndIf

;if the timer is more than 15 minutes then:
If TimerDiff($TIMER) >= 1 * 60 * 1000 Then
MsgBox (0, "Time reached", "You have been idle for more than 1 minutes.")
ProcessClose("iexplorer.exe")
Exit
EndIf



;Sleep for 1 seconds before looping again:
Sleep(1000)
WEnd

I got this script from and modified it slightly

My goal is to have this script (turned into an exe) constinatly running and looking for the app iexplorer.exe and when it is open, have this AutoIT script close it after it being idle for so many minutes. I have tried the If _Timer_GetIdleTime() variable with no luck.

Any help would be greatly appreciated

Thanks

Grimm


Thanks

Grimm

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

are you shure that win title is "iexplorer.exe"?

maybe you need ProcessExists command or WinClose WinKill instead ProcessClose if your using title?

#include <Timers.au3>
While 1
If _Timer_GetIdleTime() >= 1 * 60 * 1000 Then
     MsgBox (0, "Time reached", "You have been idle for more than 1 minutes.", 5); the trick is to set timer on msgbox to close it self after some time :P, or use some command that dont pause script
     ProcessClose("iexplorer.exe")
     Exit
EndIf
WEnd
Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

Thanks bogQ for the quick reponse.

No I am sure if the actual title is iexplorer.exe. I just used that as an example.

Quick question, I like to the script you posted, however how does the script, that you just posted, know when that app (iexplorer.exe) is open?

Thanks

Grimm


Thanks

Grimm

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

it doesnt, it checks only if user is idel for some time and try to kill process

if you need to check if proces exsist then use ProcessExists() command

eather way i whud check if win exsist cos its safer, so IE have IEFrame win class

so If WinExists('[CLASS:IEFrame]') Then WinClose('[CLASS:IEFrame]')

edit: or

If WinExists('[CLASS:IEFrame]') And WinActive('[CLASS:IEFrame]') Then WinClose('[ACTIVE]')

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

Is there a command for inactive windows?


Thanks

Grimm

Share this post


Link to post
Share on other sites

Hi, grimmlock. Have you tried the suggestions you're receiving? Both WinExists/WinClose and ProcessExists/ProcessClose will work whether the window is active or not.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Yea, I am using a combination which works great. Here is the script I am using:

I think I was able to fix the minor bugs for now =)

#include <Timers.au3>

;Declare the Timer:
; Global $TIMER = TimerInit()


While 1

    ;If this application is active then reset the timer:
;WinExists("Polaris Shortcut Bar") And 
    If ProcessExists("polaris.exe") And _Timer_GetIdleTime() >= 5 * 1000 Then 
  MsgBox (0, "Time reached", "You have been idle for more than 5 seconds.")
ProcessClose("polaris.exe")
EndIf

    ;Sleep for 1 seconds before looping again:
;    Sleep(1000)
WEnd

Thanks everyone for the help

Grimm


Thanks

Grimm

Share this post


Link to post
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
Sign in to follow this  
Followers 0