Menulet Apps

You can adress that menu item with this:

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

Thanks for the script @Tom :+1: I will also install it for myself.

1 Like

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.

1 Like

Thank you Tom. I really appreciate your help.

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.

Any ideas?

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).

That may also be an issue. If the macro works OK when the screen is awake, but not when it is asleep, what else to you need to know? :wink:

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’.

Sound like an issue with your trigger.
Try adding a hotkey trigger, and see if it works with that.

Also, in addition to playing a sound, add a "Display Window" at the top of the macro.
The macro should display the window and keep processing.

Also, I think you MUST wake the Screen, else the AppleScript UI won't work.

@stardrive, I just ran this macro and it worked for me:

Even better, this worked with a script:

1 Like

@stardrive

I can confirm that…

  • 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 :wink: (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/

@stardrive, please let me know when/if the thing works for you, so that I can uninstall the Backblaze stuff again. (I don’t like that app/company.)

Thanks.

@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.

1 Like

Thanks for the feedback, @stardrive. Fine that it works now :slight_smile:

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 :wink:

Thanks for sharing Tom.

I'm very impressed with their video, and plan to test.

As usual Tom, your choice of tools is excellent!

Looks like the only way to do this – within KM – is learn Apple Script.

Automator will also do this, using the "Record UI Events" button, and you can then save that as a Workflow that KM can run.

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?