GUI Script the ‘Dock’ shouldn’t be so difficult if we know what to look for.
- As always we use ‘class of UI elements’ to get ‘list’
- We tell list 1 of ‘class of UI elements’, didn’t give us much clue.
- We ask for the name of every UI element
- We tell UI element “Finder” to give the name of every ‘attribute’, maybe not what we need.
- We tell UI element “Finder” to give the name of every ‘action’
- If we like to do ‘AXShowExpose’ on ‘Finder’ we when use 'perform action “AXShowExpose”
- In this example we use ‘AXShowMenu’
- We tell UI element “Finder” to ‘get the name of every menu item of menu 1’
- We tell menu item “Show All Windows” of menu 1 to select
10 keystroke return
tell application "System Events" to tell process "Dock"
class of UI elements
--> {list}
tell list 1
class of UI elements
--> {UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element, UI element}
get the name of every UI element
tell UI element "Finder"
get the name of every attribute
--> {"AXRole", "AXRoleDescription", "AXSubrole", "AXTitle", "AXParent", "AXChildren", "AXPosition", "AXSize", "AXFrame", "AXTopLevelUIElement", "AXSelected", "AXShownMenuUIElement", "AXStatusLabel", "AXProgressValue", "AXURL", "AXIsApplicationRunning"}
get the name of every action
--> {"AXPress", "AXShowMenu", "AXShowExpose"}
-------------------------------------------
-- If we only like to use AXShowExpose with 'perform action "AXShowExpose"
-- we do not need the code below, 'Show All Windows' do the same thing.
-------------------------------------------
-- perform action "AXShowExpose"
perform action "AXShowMenu" --> Show the menu
get the name of every menu item of menu 1 --> Get the name of every menu item
tell menu item "Show All Windows" of menu 1 to select
keystroke return
end tell
end tell
end tell