How to Run Daily Tasks (That Need to Control the UI)

Some of my macros need to be run each day, but only when the computer is logged into but idle (as they use UI control to make changes).

This is my starting point, but can you think of any extra steps I should include or changes I should make...? (thanks to those who've already contributed)

Thanks,
Steve

Daily tasks.kmmacros (10 KB)

And the "Display warning message" macro it calls:

Display a message and wait for it to fade away.kmmacros (6.5 KB)

You can use cron triggers, so they can run on certain days/time – i.e. one time every Monday.

Thanks. I'm using Time of Day Triggers for other things ... but they don't work for macros that need UI interaction, as the Mac needs to be awake, unlocked, and ideally idle (so the user isn't interrupted) before it runs.

Do you use a Bluetooth keyboard / trackpad? If so you could turn off bluetooth at the beginning and turn it back on again at the end, to make sure that you don't accidentally interfere with it.

:joy:

(Not a serious recommendation, it looks like you've thought of the other things I would have suggested.)

1 Like

Hi, TJ

If I thought I could quickly and reliably toggle them off and back on that wouldn't be a bad idea :wink:

I've experimented with using blueutil (installed via HomeBrew - and as mentioned in the forum ages ago) for connecting my AirPods, but it's not always been 100% reliable, so I don't want to risk it with my keyboard and mouse!

Best wishes,
Steve

Fair enough!

I've been using my Magic Keyboard and Trackpad via USB because of the intermittent Bluetooth issues in Big Sur on M1 Macs, and it's actually kind of nice to not have to worry about charging them.

1 Like

@coordinated - I really like your AppleScript; nice work. I've got one that does the same, but is much less eloquent, so I'm learning a lot from yours.

My use case appears to be exactly the same as yours. I use Obsidian on iPad rather exclusively these days and all of my markdown files start with the date format you're using. I too have been looking to automate the process so that it runs just after midnight and is available across all of my Apple products, but I can't crack the code on logging in for the GUI interaction piece. So far I've, unsuccessfully or partially-successfully, tried:

Sadly, none of these are doing the trick. I even tried implementing auto-login for a bit, but quickly reverted when that didn't resolve the inability to login unattended.

I just can't imagine that there's not an easier way to automate the process in this day & age. I will keep poking at the automation part, but for now I'm saddled with stumbling down to my laptop, logging in and kicking off my AppleScript to update my Settings/General/Keyboard/Text entries.

Thanks, John - that's kind of you to say. I'm still (re)learning AppleScript, years after I originally started, and I'm doing a lot of borrowing from other peoples' scripts (I'm trying to cite them where I can).

Btw, I've just updated the AppleScript (in the related post about automating keyboard substitutions) which appears to have solved some issues).

I've also added an extra check to the "Daily tasks" script above which checks whether it can see the Apple menu icon (as an extra check that the screen is not locked - as checking the SCREENSAVER function didn't seem sufficient, and the script still running when the screen )...

Daily tasks.kmmacros (24 KB)