grimmlock Posted December 12, 2012 Posted December 12, 2012 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) WEndI got this script from and modified it slightlyMy 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 appreciatedThanksGrimm Thanks Grimm
bogQ Posted December 12, 2012 Posted December 12, 2012 (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 December 12, 2012 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) 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.
grimmlock Posted December 12, 2012 Author Posted December 12, 2012 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
JohnOne Posted December 12, 2012 Posted December 12, 2012 ProcessExists() AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
bogQ Posted December 12, 2012 Posted December 12, 2012 (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 December 12, 2012 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) 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.
grimmlock Posted December 13, 2012 Author Posted December 13, 2012 Is there a command for inactive windows? Thanks Grimm
Moderators JLogan3o13 Posted December 13, 2012 Moderators Posted December 13, 2012 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. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
grimmlock Posted December 13, 2012 Author Posted December 13, 2012 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
itauto3 Posted May 24, 2018 Posted May 24, 2018 This solution works, but there's other problem we are facing now. Our application (it's processes are closed using similar script as in this thread) doesn't detect this as logout, so user status/session is still seen as 'login' instead of 'logout'. If we click on X in application window, this is regarded as 'logout' as it should be. Any suggestions?
ViciousXUSMC Posted May 24, 2018 Posted May 24, 2018 I would start a new thread, this one is from 2012. Give us the details about what program it is if possible, instead of closing the process, finding a way to interact with the program to close it may be a better solution for you.
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