run script when system is idle?

Discussion in 'Mac Programming' started by yukonluke, Aug 10, 2012.

  1. yukonluke
    Expand Collapse
    macrumors newbie

    Aug 10, 2012
    Hey all, I'm new here (and a novice scripter) so please be gentle.

    I wrote a little applescript to cycle between "spaces" every 30 seconds, but I only want it to run when the system is idle (no keyboard or mouse input) and I want it to stop if someone uses the keyboard or mouse while the script is running.

    A few other things:
    - I'm not necessarily limited to applescript, but I'm a noob. I did a bit of googling, and found something that used python to detect mouse movement, but I couldn't wrap my head around it. I'm hoping to get this working using applescript and/or bash.

    - The script calls a key code, so I don't know if that will interfere with the "idle" state

    - both the mouse and keyboard are connected via bluetooth, so maybe it could just detect bluetooth input instead of mouse & keyboard.... I don't know.

    Any help you could provide would be greatly appreciated.
    Thanks in advance.

Share This Page