Skip to content

Instantly share code, notes, and snippets.

@pwc3
Last active October 26, 2015 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pwc3/9754912 to your computer and use it in GitHub Desktop.
Save pwc3/9754912 to your computer and use it in GitHub Desktop.
tell application "System Events"
tell process "Tweetbot"
repeat
-- need to put this in a try block as it sometimes fails
try
-- loop over all of the windows
repeat with _window in windows
-- if the title isn't "Main Window"...
if title of _window is not "Main Window" then
-- ... close it by performing AXPress on button 1 (which corresponds to the red stoplight button)
tell _window
tell button 1 to perform action "AXPress"
end tell
end if
end repeat
end try
if (count of windows) is 1 then exit repeat
end repeat
end tell
end tell
beep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment