My "Wait for Dropbox" macro has stopped working recently!

Any thoughts as to why?

This is the core AppleScript:

Auth: Christopher Stone

dCre: 2015/07/19 01:47

dMod: 2015/09/06 13:00

Appl: Dropbox and System Events

Task: Get Dropbox Status

Tags: @Applescript, @Script, @System_Events, @Dropbox, @Status

Updated by Ike Nassi 2020-07-14

tell application "System Events"
tell UI element "Dropbox"
tell menu bar 2
tell menu bar item 1
set dropBoxStatus to help

			# Uncomment to click the Dropbox menu icon.
			# perform action "AXPress"
			
		end tell
	end tell
end tell

end tell

--set kmVariableName to "DropBoxIke"
--tell application "Keyboard Maestro Engine"
-- try
-- set value of kmVariableName to dropBoxStatus
-- on error
-- make new variable with properties {name:kmVariableName, value:dropBoxStatus}
-- end try
--end tell

return dropBoxStatus

It returns my Dropbox status fine... did you recently do an OS update, or change your menu bar settings in any way?

GUI AppleScript is heavily dependent on the way you have your screen setup... so if you remove the Dropbox icon from the menu bar for instance, this script will fail.

Also, to make it easier to read the script, you should wrap the entire thing in three grave accents ``` to preserve the formatting. I had to copy and paste into Script Debugger to be able to read it :wink:

Edit: One more thing @ikenassi, what is your macro supposed to do? Because both your click icon and set variable portions of the script are commented out, so this script really doesn’t do anything except return Dropbox's status, but doesn’t do anything with that unless you are saving that as a variable via the KM AppleScript action.

I actually don't know what was wrong with it. Yes, I've updated MacOS many times over the last few years, but this is the first time this macro broke. It might have been some security setting, but now that seems unlikely. Be that as it may, I rewrote it. This version works:

Wait for Dropbox.kmmacros (5.1 KB)

1 Like

Just experimenting with the suggestion to use three grave accents:

# Auth: Christopher Stone
# dCre: 2015/07/19 01:47
# dMod: 2015/09/06 13:00
# Appl: Dropbox and System Events
# Task: Get Dropbox Status
# Tags: @Applescript, @Script, @System_Events, @Dropbox, @Status
# Updated by Ike Nassi 2020-07-14
# Updated by Ike Nassi 2021-01-29 after the last version stopped working
#
set DropBoxStatus to "Not Synced"
repeat
	tell application "System Events"
		tell UI element "Dropbox"
			tell menu bar 2
				tell menu bar item 1
					set DropBoxStatus to help
				end tell
			end tell
		end tell
	end tell
	if DropBoxStatus contains "Up to date" then return "Up to Date"
	delay 5
end repeat
1 Like

Well I'm glad you were able to figure it out! Have a great rest of you weekend :grin:

I spoke too soon. This script works on my Intel Mac, but NOT on my M1 Mac! Both are running the exact same version of MacOS.

Hmm... I have an M1 but it's running a different OS than my Intel iMac but...

I haven't seen UI element used in conjunction with System Events in awhile... what if you changed that for application process "Dropbox"?

Either way, what error code if any is it returning? Can you run the script in an AppleScript editor, preferably Script Debugger (far superior to Apple's native Script Editor) to see what the issue is?

I tried that already. It makes no difference. The problem is the value of the "help" element is missing on the M1, but is present on the Intel version. Looks like the AppleScript implementation is different, somehow. My copy of script debugger immediately crash, so I upgraded it. I got this message running my script when I tried to access "help". I don't understand what it's trying to tell me.

'obj '{ 'form':'indx', 'want':'mbar', 'seld':2, 'from':'obj '{ 'form':'name', 'want':'pcap', 'seld':'utxt'("Dropbox"), 'from':[0x0,9e09e "System Events"] } }

Here's the script:

set DropBoxStatus to "Not Synced"
tell application "Dropbox" to activate
repeat
	tell application "System Events"
		tell application process "Dropbox"
			tell menu bar 2
				-- display dialog (UI elements) as string
				tell menu bar item 1
					set DropBoxStatus to help
					-- display dialog DropBoxStatus as text
				end tell
			end tell
		end tell
	end tell
	if DropBoxStatus contains "Up to date" then return "Up to Date"
	delay 5
end repeat

It looks like the UI elements in the application process "Dropbox" are missing on the M1, but not on the Intel machine.

I'm not so sure about that because I ran both your original AppleScript and this latest one on my M1 MacBook Air just now and both work for me...

I'm kind of at a loss for the moment but I'll try and take a closer look tomorrow when my brain is fresh(er) :sweat_smile:

I consider this very good news

nassi@nassi.com
www.nassi.com/
+1-408-390-8281

Beware fat thumbs

Can you try this AppleScript to see if it works on your M1?

----------------------------------------------------------
# Author:				Chris Thomerson (@cdthomer)
#
# Current Version:		1.0 (Initial script)
# Version History:		1.0 (Initial script)
#
# Created:				Monday, January 31, 2022
# Modified:				Monday, January 31, 2022
# macOS:				12.1 (Monterey)
# Tags:					Dropbox, Syncing
#
# DISCLAIMER
# Permission to use, copy, modify, and/or distribute this
# software for any purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
# THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
----------------------------------------------------------

tell application "System Events" to tell application process "Dropbox"
	
	(*
		set attNames to every attribute of menu bar item 1 of menu bar 2
		set attValues to value of every attribute of menu bar item 1 of menu bar 2
	*)
	
	if value of attribute "AXHelp" of menu bar item 1 of menu bar 2 contains "Up to date" then
		set dbStatus to "Up to date"
	else
		set dbStatus to "Syncing"
	end if
	
end tell

dbStatus

First: Thank you!
Second: It always returns "Syncing" whether that's true or not.

added debugging statement. It returns "missing value" as before.

----------------------------------------------------------
# Author:				Chris Thomerson (@cdthomer)
#
# Current Version:		1.0 (Initial script)
# Version History:		1.0 (Initial script)
#
# Created:				Monday, January 31, 2022
# Modified:				Monday, January 31, 2022
# macOS:				12.1 (Monterey)
# Tags:					Dropbox, Syncing
#
# DISCLAIMER
# Permission to use, copy, modify, and/or distribute this
# software for any purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
# THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
----------------------------------------------------------

tell application "System Events" to tell application process "Dropbox"
	
	(*
		set attNames to every attribute of menu bar item 1 of menu bar 2
		set attValues to value of every attribute of menu bar item 1 of menu bar 2
	*)
	
	if value of attribute "AXHelp" of menu bar item 1 of menu bar 2 contains "Up to date" then
		set dbStatus to "Up to date"
	else
		-- display dialog "Huh? " & (value of attribute "AXHelp" of menu bar item 1 of menu bar 2)
		set dbStatus to "Syncing"
	end if
	
end tell

dbStatus

Sorry but I'm a little confused then... when I run the script with set attNames and set attValues lines, this is what it returns:

I've highlighted the relevant attribute we use to get sync status. As you can see, on my M1 the value is "Dropbox 140.4.1951\nUp to date". What missing value are you referring to? And what do you mean it always returns "Syncing"? For me, the only time it returns syncing is if it is indeed syncing file(s).

I ran it both in script editor, and script debugger. In neither case did I observe what you see.
Here's my screenshot:

Oh... those lines were commented out in what you sent me. I'll uncomment and try again.

1 Like

Here you go:
Screen Shot 2022-01-31 at 10.09.00 AM

Well bugger.... I know Dropbox has some issues because it is still not designed to run natively on M1, but I don't recall having seen this problem before. I have no clue why it's happening but it's most definitely an issue with Dropbox as it is not supplying the normal accessibility information that it should.

Remind me of what OS you're running?

MacOS 12.2.