Is there a way to check if user is on computer/active?

So I want the macro to be able to decide whether or not I am doing something on the computer or not.
If it detects that I am doing something, then I want it to do something, else store a variable that I am not active which can be utilized by another macro as if then else condition

I see there's a trigger, if mac is idle (which I can use to set - variable user "away") however is there a way to set variable user "active" when the user becomes active?

Thanks in anticipation

I presume you're talking about a macro with a periodic trigger? It would be faster and easier to answer your question if you followed the advice in Tip: How Do I Get The Best Answer in the Shortest Time?, as @JMichaelTX has linked to you before. At any rate, based on what I can make out from what you describe, this sounds like a job for the IDLE() function:

If Then Else.kmactions (1.1 KB)

1 Like

Wow. Thanks a lot.

Suppose I am away for 5 minutes (ie IDLE = 300), now if my macro runs and checks for IDLE() > 60, will it wait 60 seconds before declaring computer as IDLE or it would know computer is IDLE () for 300 seconds and hence will run instantly?


You're welcome. It would only pause for 60 seconds if you included a pause action for that length of time. If you've been away for five minutes, the macro will see that IDLE() > 60 and run the next action instantly.

1 Like

Thanks mate!
Really appreciate the help!

1 Like

Oh silly question, but I know it looks for mouse/keyboard interaction, but does this include KM generated mouse movement?
I mean I have a "move and click mouse" action just before I want to check for IDLE()>60, would it still work?


KM generated mouse movement does reset the IDLE() timer (or at least, it appears to in my tests) so I'm afraid you would either need to have the IDLE()-based part of your macro run before the mouse click part, or have the macro pause for as many seconds as you want IDLE() to track after clicking before checking its status.

ah man, that complicates things.
@peternlewis any inputs on this?

basically I want the computer to auto-click on image on screen only if I am not there on the computer for >30 seconds.

however, if I am there (ie actual human mouse/keyboard movement not KM action generated) then it should not click on it as I will want to do that manually when I am available.

Is a mouse click the only way to accomplish whatever it is you're trying to do? Again, it would help me and anyone else interested in helping you if you followed the advice described in Tip: How Do I Get The Best Answer in the Shortest Time? and shared your entire workflow/current macro with us.

I think I'll have to use click on image, I am clicking on the I'm not a robot of google recaptcha with it.

I think it likes it when there's an actual user interaction instead of auto-clicking using js?


Hmm. What about having a separate macro use an idle trigger to set a variable once the computer has been idle for however long you want, and checking that instead of IDLE() when you want to make sure the user is away?

was planning to use that, but how would I change the variable back to active?
can't seem to find a trigger that caters to that

I second the desire to have something (maybe an option/flag on the key and mouse actions) that does NOT cause the IDLE detection to be reset. Occasionally the lack of such an option causes me some grief.

One idea is to have another macro that's triggered by any kind of user activity, like typing, activating an app, or changing the window, then disables itself so it isn't firing all the time:

Make User Active.kmmacros (2.1 KB)

And have the idle trigger macro enable it at the same time it sets the variable to "away":

Make User Away.kmmacros (1.5 KB)


That's very impressive, GG. I always learn things here on this forum. Every day I seem to earn my nickname "Sleepy" here.

The IDLE() function returns the system’s concept of the idle time, so it a simulated click resets it, that's what you get I'm afraid - it is not something I can account for in Keyboard Maestro.