How Can You Tell if Dropbox Has Finished Syncing?

This is not about sync-ing KM macros.

I want to perform an action on some data stored in Dropbox. If Dropbox is currently sync-ing, I wan to wait until it’s finished. If it’s not sync-ing, I want to perform it as soon as possible.

I could use the “found image” condition, and build the capability around the difference in the various dropbox icons, but generally would only use that as a last resort.

How can I tell that Dropbox is in the middle of syncing files?

Hey Ike,

There’s not a neat, organic way to do this as far as I know.

It should be possible to simply ask Dropbox what it’s doing, but they haven’t provided a scripted interface for the Mac.

The is a workaround however using AppleScript and System Events.

You can run this from the Script Editor to see what it does.

------------------------------------------------------------
# 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
------------------------------------------------------------

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 "myVariableName"

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

You’ll get output that looks like this:

"Dropbox 3.9.41
Uploading \"Aquamacs-Emacs-3.2.dmg\" (481.8 KB/sec, 1 min left)"

Or this when Dropbox is synced up.

"Dropbox 3.9.41
Up to date"

So your macro can test for whatever-variable-name contains “Up to date” and continue when it does.

-Chris

1 Like

This worked out great. Thank you so much. Following up: what is the quickest way to learn the subset of Applescript I need to know to get by with KM?

Hey Ike,

That depends upon how much AppleScript you know already.  :smile:

Here are a couple of resources.

References For Learning & Using Applescript

Learning & Using AppleScript & JavaScript for Automation (JXA)

You can look at the Keyboard Maestro Editor and the Keyboard Maestro Engine AppleScript dictionaries (sdef) in Script Editor.app.

-Chris

Can anyone help update this script for Box.com? Would love to be able to tell if it’s currently syncing or not. Thanks

Hey Adrian,

Apple broke this approach in Sierra, and I don’t know if it’s fixed in High Sierra.

On my Sierra system this takes over 6 seconds to run.

------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2015/07/19 01:47
# dMod: 2017/12/02 05:44
# Appl: Box Sync and System Events
# Task: Get Box Sync Status
# Tags: @Applescript, @Script, @System_Events, @Box_Sync, @Status
------------------------------------------------------------

tell application "System Events"
   tell UI element "Box Sync"
      tell menu bar 2
         tell menu bar item 1
            
            perform action "AXPress"
            
            tell menu 1
               
               tell menu item 1
                  set syncStatus to its enabled
               end tell
               
               perform action "AXCancel"
               
            end tell
            
         end tell
      end tell
   end tell
end tell

------------------------------------------------------------

Hopefully Apple fixed it in High Sierra.

Run it from the Script Editor.app to see.

-Chris

1 Like

Thanks, upon running that code in High Sierra, the Box menu opens so I it appears the code is working.

However the Script output wasn't a clean "Still Uploading" or "Files Synced" status

Any thoughts on how to fix that? Also how can I set this to a variable in Keyboard Maestro?

1 Like

Hey Adrian,

Does it run quickly? Or does it hang for 6 seconds or so?

-Chris

It hangs for 6 seconds or so

Hey Adrian,

@JMichaelTX gave me an idea of how to speed that up.

Try this one.

-Chris

----------------------------------------------------------------
# Auth: Christopher Stone (with input from @JMichaelTX)
# dCre: 2015/07/19 01:47
# dMod: 2017/12/09 22:49
# Appl: Box Sync and System Events
# Task: Get Box Sync Status
# Tags: @Applescript, @Script, @System_Events, @Box_Sync, @Status
----------------------------------------------------------------

try
   
   ignoring application responses
      tell application "System Events"
         tell UI element "Box Sync"
            tell menu bar 2
               tell menu bar item 1
                  perform action "AXPress"
               end tell
            end tell
         end tell
      end tell
   end ignoring
   
   set shCMD to "killall 'System Events'"
   do shell script shCMD
   
   tell application "System Events"
      tell UI element "Box Sync"
         tell menu bar 2
            tell menu bar item 1
               tell menu 1
                  tell menu item 1
                     set syncStatus to its name
                  end tell
                  perform action "AXCancel"
               end tell
            end tell
         end tell
      end tell
   end tell
   
   syncStatus
   
on error e number n
   set e to e & return & return & "Num: " & n
   if n ≠ -128 then
      try
         tell application (path to frontmost application as text) to set ddButton to button returned of ¬
            (display dialog e with title "ERROR!" buttons {"Copy Error Message", "Cancel", "OK"} ¬
               default button "OK" giving up after 30)
         if ddButton = "Copy Error Message" then set the clipboard to e
      end try
   end if
end try

----------------------------------------------------------------

Although this is an old topic (nearly 4 years), I just ran across it again when I needed this exact capability.

Chris @ccstone gave us the basic solution here:

I took Chris' script and turned it into a KM Action Group "Pause Until DropBox Sync Completes". I have confirmed this runs fine with Keyboard Maestro 8.2.4 on macOS 10.14.5 (Mojave).

Here's an upload of these ACTIONS which you can insert where ever you need them:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ACTIONS: Pause Until DropBox Sync is Complete

DOWNLOAD: When you Import These Actions they will be placed after the currently selected Action in the current macro.

Pause Until DropBox Sync is Complete.kmactions (3.1 KB)

You may need to adjust the "Pause Until" Action to set the Action timeout to suit your use case:

image

Hey all,

I believe that @JMichaelITX's solution doesn't work anymore with newer version of Dropbox. It worked for me for a good few years, but, when I run their script now, it returns the following error:

2022-03-11 17:57:13 Execute an AppleScript failed with script error: text-script:1124:1134: execution error: Can’t get every paragraph of missing value. (-1728)

I have tried a bit to fix it. Unfortunately, I am not that experienced with Applescript.

Does anyone have a solution to fix this script?

(I understand that JMichaelITX has passed away. RIP.)

Revised as promised:
There is an acknowledged bug in Dropbox. Dropbox is not returning the correct status on all platforms. I noticed it on the Apple M1. They acknowledged that it’s their bug. But since I’m the only one that reported it, it stuck at a low priority. Please report it to Dropbox.

I have a workaround, in KM, but it’s a hack. Dropbox must fix it.

Wait for Dropbox for M1.kmmacros (41.2 KB)

Thanks, @ikenassi! Can you share the message you sent to Dropbox, so I can tweak/rewrite it and share a similar message with them? Also, how did you report it to the? I don't see a way to do so.

Here you go. I had to upload in two pages, each had to be a jpg. I sent the original report to their support site, and when they asked for more info, I sent them this info, which I generated from Xcode's Accessibility Inspector Developer Tool:

DB I found a bug in DropBox on the M1
DB I found a bug in DropBox on the M1

@ikenassi,

This appears to be fixed btw.

The menubar icon for Dropbox updates the status in the Help property again.

2022-10-10_12-43-51

1 Like

I agree. It’s been fixed for a while on both Intel and M1.

1 Like