dangustaargus

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

11 posts in this topic

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

Share this post


Link to post
Share on other sites



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

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by dangustaargus
misspelling

Share this post


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:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


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

Share this post


Link to post
Share on other sites

What exactly does that do? I'm not terribly familiar with all of the functions available to me, and their purpose.

Share this post


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?

Share this post


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


Active: IRC UDF, WindowEx UDF
Discontinued: GithubBubbleSort UDF

Share this post


Link to post
Share on other sites

Thanks everyone for the help. I sincerely appreciate it.

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