Accessing dock icon right-click menu items with AppleScript

后端 未结 5 669
醉酒成梦
醉酒成梦 2020-12-16 23:39

Is there any way to get an AppleScript to access the menu items that come up when you right click on a dock icon?

Specifically, here\'s what I want to do:

I

5条回答
  •  时光取名叫无心
    2020-12-17 00:35

    Not sure if you are still interested but...

     tell application "Dock"
        activate
    end tell
    tell application "System Events"
        tell process "Dock"
            set frontmost to true
            activate
            tell list 1
                perform action "AXShowMenu" of UI element "Google Chrome"
                delay 1
                repeat 4 times -- count number of items to the one you want
                    key code 126 -- up arrow
                    -- key code 125 -- down arrow
                end repeat
                delay 1
                repeat 2 times
                    key code 36 -- return key
                end repeat
            end tell
        end tell
    end tell
    

提交回复
热议问题