Created
June 1, 2020 10:51
-
-
Save OKsign/f89e30fe6715a8be81d49279c5301200 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- user options | |
set ignored_apps to {} | |
set get_name_of_active_app to "off" -- "on" or "off" | |
set default_button_of_dialog to "Quit" -- "Quit" or "Cancel" | |
-- end of user options | |
try | |
if get_name_of_active_app is "on" then | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
end tell | |
if activeApp is "Finder" then | |
display dialog "There Is No \"Command+Q\"in Finder" with title "Script 44" | |
return | |
end if | |
set clip to "\"" & activeApp & "\"" | |
set the clipboard to clip | |
delay 1 | |
display dialog "Paste Name of Active App to Script File." with title "Script 44" | |
end if | |
if get_name_of_active_app is "off" then | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
end tell | |
if activeApp is not "Finder" then | |
if activeApp is not in ignored_apps then | |
set quit_or_cancel to (display dialog "Are You Sure You Want to Quit \"" & activeApp & "\"?" buttons {"Cancel", "Quit"} with title "Script 44" default button default_button_of_dialog) | |
delay 1.5 | |
if activeApp is "soffice" then | |
tell application "System Events" | |
tell process activeApp | |
set the frontmost to true | |
delay 0.3 | |
click (menu bar item "File" of menu bar 1) | |
delay 1 | |
end tell | |
end tell | |
tell application "System Events" | |
key code 123 | |
delay 0.5 | |
keystroke "quit" | |
delay 0.5 | |
key code 36 | |
end tell | |
else | |
tell application "System Events" | |
tell process activeApp | |
set the frontmost to true | |
end tell | |
end tell | |
tell application activeApp | |
quit | |
end tell | |
end if | |
else | |
if activeApp is "soffice" then | |
tell application "System Events" | |
tell process activeApp | |
set the frontmost to true | |
delay 0.3 | |
click (menu bar item "File" of menu bar 1) | |
delay 1 | |
end tell | |
end tell | |
tell application "System Events" | |
key code 123 | |
delay 0.5 | |
keystroke "quit" | |
delay 0.5 | |
key code 36 | |
end tell | |
else | |
tell application "System Events" | |
tell process activeApp | |
set the frontmost to true | |
end tell | |
end tell | |
tell application activeApp | |
quit | |
end tell | |
end if | |
end if | |
end if | |
end if | |
on error number -128 | |
tell application "System Events" | |
tell process activeApp | |
set frontmost to true | |
end tell | |
end tell | |
end try |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment