anavdesign
6/27/2016 - 7:53 PM

AS: Quit Safari

AS: Quit Safari

--https://discussions.apple.com/thread/7465555?start=0&tstart=0

-- 1. Create New Application to Clear Safari Cache and Quit application
-- Open Automator
-- Choose new Application
-- Find "Run Applescript" and add it to the rightside workflow panel
-- Copy and paste the following script
-- Find Quit Application
-- Select Safari from drop-down menu
-- Save application as "Quit Safari"
-- Quit Automator

-- 2. Allow the application to control your computer
-- Upon first run of the application, a security notice will appear
-- To see if your application has permission go to System Preferences > Security & Privacy > Accessibility
-- Your app should be listed and have a check in the check box.

-- 3. Create New Service to run "Quit Safari" application
-- Open Automator
-- Choose new Service
-- Find Launch Application
-- Set Service receives to "no input" in "Safari"
-- Save service as "Quit Safari + Clear History"

-- 4. Change default Safari Quit keyborad Shortcut
-- Go to System Preferences > Keyboard
-- Click the "Keyboard Shortcuts" tab
-- Click "Application Shortcuts"
-- Add a new shortcut for Safari
-- Menu Title "Quit Safari"
-- Keyboard Shortcut "command+option+control+Q"

-- 5. Set Quit Safari Service keyboard shortcut
-- Click "Services"
-- Select "Quit Safari + Clear History"
-- Make keyboard shortcut: command+Q

on run {input, parameters}
  tell application "Safari"
  close every window
  end tell
  set theApp to "Safari"
  set mt to 6
  set mi to -2
  tell application "System Events" to tell process theApp
  set frontmost to true
  tell menu bar 1 to tell menu bar item mt to ¬
  tell menu 1
  click menu item mi
  end tell
  tell window 1
  click button 2
  end tell
  end tell
  return input
end run