tell application "System Events"
tell application process "bzbmenu"
tell menu bar 1
tell menu bar item 1
perform action "AXPress"
end tell
end tell
repeat 2 times
key code 125 -- Down Arrow
end repeat
key code 36 -- Return
end tell
end tell
Forget my old script from above. This one runs faster:
tell application "System Events"
tell application process "bzbmenu"
tell menu bar 1
tell menu bar item 1
try
with timeout of 0.1 seconds
perform action "AXPress"
end timeout
end try
end tell
end tell
end tell
end tell
do shell script "killall 'System Events'"
tell application "System Events"
repeat 2 times
key code 125
end repeat
key code 36
end tell
It’s an ugly hack to bypass the strange delay (OS bug?) as already mentioned here.
If you don’t see any delay with my previous script then… use the previous script.
To test this, I added a 'Play Sound' action before and after the script, so I could tell if it was working even when my display is asleep.
When using the 'At time' trigger, and the display asleep, I heard the first sound, then the second sound after a 2 minute delay. However the menu item was not selected and the backup did not begin. When the screen was awake, the result was the same. I did not see the Backblaze menu open, I just heard the two sounds with a 2 minute delay.
Strangely, when I ran the macro manually by clicking the 'Try' button, I heard the first sound, then I saw the menu open, select the correct 'Backup' menu item, then the second sound played. In this case the backup was successfully initiated.
So it seems that it almost works, but unfortunately not under the conditions I need it to, namely with the 'At time' trigger and the screen asleep.
As mentioned by @peternlewis in another topic, you can't use UI scripting or KM UI actions when the Mac is asleep.
So, you need to first wake the Mac before running the script/macro. You probably need an AppleScript set to execute at a given time. Do some searching on "AppleScript to wake Mac", or similar.
Yes, thank you. I do understand that. To clarify, my computer is set to never sleep. It is only the display that is asleep. I can tell that the computer is awake because I can hear the sounds executed by the macro and see the power light remains dimly illuminated (not pulsing).
Thank you. Unfortunately, the macro does not work whether or not the display is asleep as I described. It only works when I manually click ‘Try’, not when triggered via ‘At Time’ which is what I need. Again, the sounds play so I know the macro runs, but the script does not work except when I click ‘Try’.
The AppleScript does nothing when launched via KM Time Trigger and the screen is sleeping
An initial Wake Screen action as @JMichaelTX has shown solves the problem (on my machine)
Some tips:
To be on the safe side maybe throw in a short Pause action after the Wake action.
Since you’re exclusively using a timed trigger you can as well use the first version of the script as posted here. That script is “cleaner” and the mentioned delay is irrelevant if it runs in the middle of the night (The delay is about 5s on my Mac.)
If you are experiencing any problems with the script – and especially if you are using the second version of the script – make sure that System Events.app is check-marked in System Preferences > Security & Privacy > Privacy > Accessibility. See this post. [1]
If you use the second version of the script you also want to play around with the timeout value.
I noticed that – on my system – Backblaze’s menu items don’t always reflect the actual status. That is, after the script has run it may still show “Backup Now”. If I wait a couple of seconds and then simply open the menu again it shows “Pause Backup”.
[1]: If you have to add it manually you find it in /System/Library/CoreServices/
@Tom and @JMichaelTX - Thank you so very much. The helpfulness and care in this forum is amazing.
Per your advice, I added the Wake Screen action and also went back to the first version of Tom’s script, plus added a 1 second pause before the script.
I tested with the screen asleep and the At Time trigger and it worked perfectly. At the set time, the screen woke up, and the menu item was successfully selected from the applet.
I really appreciate your help!
Side Note: I’d be curious to know what alternatives to Backblaze you might recommend. It’s funny. Backblaze does actually have a timer function, but for some reason, even with that set it insists on running a ‘preparing backup file list’ process every hour which slows my system to a crawl for several minutes. The reason I needed this macro is to prevent that from happening by keeping it set to manual. I like the service otherwise.
Thanks for the feedback, @stardrive. Fine that it works now
I'm using Arq Backup with OneDrive as backup destination (the 1TB that comes with the Office365 subscription). If I run out of space I will add some Glacier or S3 storage.
(Of course, this is in addition to a local Time Machine backup, and regular clones of the startvolume to external drives.)
I'm doing this for a couple of months now. Previously I was using CrashPlan for several years but cancelled in June, because it was painfully slow (upload and restore) and it was constantly consuming about 1GB of memory. (Arq: ~70MB).
As it happens, today I posted a (not so positive) comment about Backblaze on Michael Tsai's blog
This is an older thread, but I’m wanting to do exactly this: toggle Backblaze to pause or resume synching. Unfortunately, this solution is not working for me, although I have several similar macros that pause Google Drive and Dropbox.
I’m using Monterey 12.0.1. Has something changed? How can I get this to work?