dangustaargus Posted November 16, 2015 Share Posted November 16, 2015 Hi all,I'm fairly new to using this program (I've successfully used it to write one small program that forces a list of exe's to focus) and I thought I'd ask for help here before I waste a week trying to write something without a lot of experience. Basically I'm looking for some code along the lines of my topic title:I have a handful of exe's (games) that I will be launching from a separate program I've written in Java, and, because I can't necessarily control those applications after my Java app loses focus, I needed something that would begin a timer to determine that the user has stopped playing the games through a lack of keyboard and mouse input. Basically, if after 5 minutes passes with no further inputs, kill one of the listed processes and return focus to my program.I hope that was clear and thanks,Anthony Link to comment Share on other sites More sharing options...
Developers Jos Posted November 16, 2015 Developers Share Posted November 16, 2015 I have removed 2 duplicates and like to point you first to our forumrules, especially the part about game automation.Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
dangustaargus Posted November 16, 2015 Author Share Posted November 16, 2015 (edited) I read the rules. This has nothing to do with commercial games.I am building kiosks for a museum exhibition featuring the work of a video game artist and have written a java app that allows visitors to launch a game of their choosing from a list. The game launches and if the visitor gets bored or walks away, I need the application to close after a certain amount of time or another visitor will find an already opened game and not understand that they can go back to choose from a complete list.That's it. I guess my other question is should I have posted this on the technical forum? Edited November 16, 2015 by dangustaargus misspelling Link to comment Share on other sites More sharing options...
water Posted November 16, 2015 Share Posted November 16, 2015 Please have a look at function _Timer_GetIdleTime to see how long a user has been idle. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
dangustaargus Posted November 17, 2015 Author Share Posted November 17, 2015 Thank you. This did the trick, and I should be able to add more applications to this code without trouble.#include <Timers.au3>While 1 ;loop to constantly check conditions If (ProcessExists("notepad.exe")) And _Timer_GetIdleTime() > 10000 Then ;if the user is idle for more than 10secs ProcessClose("notepad.exe") EndIfWEnd Link to comment Share on other sites More sharing options...
JohnOne Posted November 17, 2015 Share Posted November 17, 2015 It would be prudent to add a sleep to the loop. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
dangustaargus Posted November 17, 2015 Author Share Posted November 17, 2015 What exactly does that do? I'm not terribly familiar with all of the functions available to me, and their purpose. Link to comment Share on other sites More sharing options...
Bert Posted November 17, 2015 Share Posted November 17, 2015 (edited) the sleep function keeps your processor load down. (In the case of your code that you show). Edited November 17, 2015 by Bert The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
dangustaargus Posted November 17, 2015 Author Share Posted November 17, 2015 Thanks! The other short script I wrote actually bogs things down quite a bit and I wasn't sure why.Would I be running that outside or inside my while loop? Link to comment Share on other sites More sharing options...
rcmaehl Posted November 17, 2015 Share Posted November 17, 2015 Thanks! The other short script I wrote actually bogs things down quite a bit and I wasn't sure why.Would I be running that outside or inside my while loop?Sleeps should go inside your loop My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.My Projects WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF Link to comment Share on other sites More sharing options...
dangustaargus Posted November 17, 2015 Author Share Posted November 17, 2015 Thanks everyone for the help. I sincerely appreciate it. 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