Jump to content
Sign in to follow this  

PC environment for background services

Recommended Posts


Gidday all,

I am trying to work out a couple of things from a service I start through scheduled tasks (XP pro SP3).

I tried to implement a service that shuts the PC down if idle for a set amount of time. I know that SchTasks allows for idle as one of the startup options for a task, but it doesn't take into account there might be a multimedia item playing on the screen. So, I wrote an autoit script that times out on mouse (non)movement while looking at the screen for multimedia windows (Media Player, VLC, QuickTime etc....).

Low and behold, the machine shuts down all the time even if the mouse is moving. I think that this service starts before any logins (before users present), and it (MouseMove) doesn't relate, react or read mouse and screen controls properly. There is a reg setting to enable services to interact with the desktop, but it made no difference.

Secondly, I'd like to send a message to users who leave their machines logged on (and go home), but the username macro (and local environment variable) reports the name of the account that put the task in, not the presently logged in user.

Is there a way of getting mouse control going for a service that starts before log on and can I find the name of the presently logged in user, not the service account?


Saddle (In the land of Oz)

"Some say half full, some say half empty, I say designed correctly with a 100% safety margin, here's your bill for work completed"

Share this post

Link to post
Share on other sites


hmm, what you try to achieve doesn't really sound time critical to me. Why don't you just begin your script's loop whit something like sleep(60*1000) or a resp. timer loop (to keep script responsive)? Then I recommend you to look up function _Timer_GetIdleTime() to check if user is idle and maybe additionally do a PixelChecksum() comparison of the whole desktop to check if multimedia is running (except taskbar of course, there's always some king of activity there, at least the clock ^_^).

Additionally a search returned this interesting links:


[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer] "Logon User Name" seems to contain currently logged on user.


Edited by KaFu

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
Sign in to follow this