GUI Dock

GUI Script the ‘Dock’ shouldn’t be so difficult if we know what to look for.

  1. As always we use ‘class of UI elements’ to get ‘list’
  2. We tell list 1 of ‘class of UI elements’, didn’t give us much clue.
  3. We ask for the name of every UI element
  4. We tell UI element “Finder” to give the name of every ‘attribute’, maybe not what we need.
  5. We tell UI element “Finder” to give the name of every ‘action’
  6. If we like to do ‘AXShowExpose’ on ‘Finder’ we when use 'perform action “AXShowExpose”
  7. In this example we use ‘AXShowMenu’
  8. We tell UI element “Finder” to ‘get the name of every menu item of menu 1’
  9. 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