Jump to content

Kill list of exe's after set time when user stops pressing keys or using mouse

Recommended Posts

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,


Link to post
Share on other sites
  • Developers

I have removed 2 duplicates and like to point you first to our forumrules, especially the part about game automation.


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 post
Share on other sites

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 by dangustaargus
Link to post
Share on other sites

Please have a look at function _Timer_GetIdleTime to see how long a user has been idle.

My UDFs and Tutorials:


Active Directory (NEW 2021-06-05 - Version - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2021-06-14 - Version - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version - Download
Outlook Tools (2019-07-22 - Version - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version - Download - General Help & Support - Example Scripts
PowerPoint (2021-07-20 - Version - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version - Download - General Help & Support - Wiki

ADO - Wiki, WebDriver - Wiki


Link to post
Share on other sites

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

Link to post
Share on other sites

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

Cisco FinesseGithubIRC UDFWindowEx UDF


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

    No registered users viewing this page.

  • Create New...