Skip to content

Instantly share code, notes, and snippets.

@ctanis
Created April 26, 2013 15:51
Show Gist options
  • Save ctanis/5468298 to your computer and use it in GitHub Desktop.
Save ctanis/5468298 to your computer and use it in GitHub Desktop.
applescript to choose Finder's "remove from dock" Dock context menu option, if present -- assumes(?) that this option is the 9th line in the context menu. also it temporarily mutes the system volume so you don't hear the "poof" sound effect.
tell application "Dock"
activate
end tell
try
set oldvalue to output muted of (get volume settings)
set volume output muted 1
tell application "System Events"
tell process "Dock"
set frontmost to true
activate
tell list 1
perform action "AXShowMenu" of UI element "Finder"
delay 0.25
repeat 9 times -- count number of items to the one you want
key code 125 -- down arrow
end repeat
delay 0.25
repeat 1 times
key code 36 -- return key
end repeat
end tell
end tell
end tell
on error
end try
delay 2
set volume output muted oldvalue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment