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,

Anthony

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

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

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
misspelling
Link to comment
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:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
        ProcessClose("notepad.exe")
    EndIf
WEnd

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

WhyNotWin11
Cisco FinesseGithubIRC UDFWindowEx UDF

 

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...