0

I have an AppleScript that does a simple "mouse" click on the Dropbox menu bar icon (Menu Extra or Menulet). It works well.

tell application "System Events"
tell UI element "Dropbox"
    tell menu bar item 1 of menu bar 2
        perform action "AXPress"
    end tell
end tell
end tell

I want to edit this code so the action that will be performed is a click while the Option (alt / ⌥) is pressed down.

I've done an extensive search for a solution but didn't find any.

Thanks in advance.

1
  • Most (I think all) of the menu options in the Dropbox menu bar popup menu are also available through the standard click popup window and then a second click on the preferences icon. Perhaps accessing your desired menu items that way is the way to go.
    – CJK
    Commented Jul 14, 2018 at 6:12

1 Answer 1

2

Using terms from the (FREE) AppleScript Toolbox scripting addition, this code will handle your question.


The code in this updated answer will automatically get the coordinates of the DROPBOX icon in the status bar... Whether it's location stays the same or changes


tell application "System Events"
    tell its UI element "Dropbox"
        tell its menu bar 2
            set originalCoordinates to position
        end tell
    end tell
end tell

set itemOne to (item 1 of originalCoordinates) + 10
set itemTwo to (item 2 of originalCoordinates) + 10

set dropboxMouseLocation to {itemOne, itemTwo}
AST set mouse point location dropboxMouseLocation
AST click at dropboxMouseLocation holding modifier key ast option key

enter image description here


UPDATE

This is following version of the code will return the mouse to where its original location was before clicking on the Dropbox status menu icon


set originalMouseLocation to AST mouse point location

tell application "System Events" to tell its UI element "Dropbox"
    tell its menu bar 2
        set originalCoordinates to position
    end tell
end tell

set itemOne to (item 1 of originalCoordinates) + 10
set itemTwo to (item 2 of originalCoordinates) + 10

set dropboxMouseLocation to {itemOne, itemTwo}
AST set mouse point location dropboxMouseLocation
AST click at dropboxMouseLocation holding modifier key ast option key

AST set mouse point location originalMouseLocation
10
  • 1
    Love your Gifs! What program do you use to create it? Commented Jul 10, 2018 at 3:56
  • gifbrewery.com is generally what I use for animated GIFs
    – wch1zpink
    Commented Jul 10, 2018 at 13:46
  • 1
    @voronoi I have tried every other possible approach I could think of... The only solution I can get to work is the original solution I posted.
    – wch1zpink
    Commented Jul 14, 2018 at 22:44
  • 1
    @voronoi Great question... Updated the code. It's no longer necessary to manually set coordinates. Now wherever the dropbox icon sits, the code will automatically work
    – wch1zpink
    Commented Jul 17, 2018 at 16:24
  • 1
    The code "set originalCoordinates to position" returns the location where the upper left corner of the placement of the icon sits. So if "set originalCoordinates to position" returns {1083, 0}, adding +10 to each one of those values will give us these new coordinates... {1093, 10} <--- which is actually where we want the mouse to click. Code updated as per your request. Don't forget to mark my post as the accepted answer ;-)
    – wch1zpink
    Commented Jul 19, 2018 at 14:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .