Jump to content

Detecting Mouse/Keyboard input without a GUI


Recommended Posts

Here's my situation. I have a script that I want to run to close a program when I leave work at the end of the day which causes data to be synced to dropbox and thus my home computer. This syncing has to happen before I get home at night otherwise I have data sync issues. The problem is that I regularly leave anywhere between 4:30 and 7:00pm (and occasionally even earlier). I setup Windows Task Scheduler to run my script when the workstation locks, which works great... except that the program closes when I leave for 20 minutes to grab lunch at noon... which I'd prefer not to happen if I can help it. I then setup the script so that it doesn't do anything if it's before 4pm, but if for some reason I leave one day at 3pm, the script would fire, not do anything, and then I could lose my data from that day.

What I think would work best is if I had the script running constantly in the background, checking once a minute for mouse/keyboard input and if it's been X minutes since the last input was received, close my program. Then I could vary X based on the time of day... longer timeouts during the mornings when I'm likely to leave for lunch/meetings and a short 30 minute timeout after 4:30 when I'm likely to be driving home.

I've looked at the examples and seen how you can retrieve mouse moves using GUIRegisterMsg, but I don't want to have a gui at all. It seems I could just use MouseGetPos, but I figured I'd want to use _Timer_SetTimer to avoid killing my CPU in some kind of stupid tight loop, but that requires a GUI as well it seems. I'm not sure at all how to detect keyboard input though. It would be pretty rare for me to be here and not use the mouse in an hour, so I figure I can live without that though.

Anybody have any suggestions on how this should work?

Link to comment
Share on other sites

is maby _Timer_GetIdleTime() wat you need?

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

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