Jump to content

Recommended Posts

Posted

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

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
Posted

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 2024-07-28 - Version 1.6.3.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 (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

 

Posted

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

Posted

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, MSEdgeRedirect
Cisco FinesseGithubIRC UDFWindowEx UDF

 

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
×
×
  • Create New...