Created
November 23, 2021 10:15
-
-
Save OKsign/726804b3848fd2877d0f94a0ae51a8bf 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
-- Adjust resolution in Preview | |
-- open system preferences > keyboard > tab 'Shortcuts' > check 'Use keyboard navigation to move focus between controls' | |
-- user input | |
set resolution to "144" | |
-- end of user input ----------------------------------- | |
if application "Preview" is running then | |
set prun to 1 | |
else | |
set prun to 0 | |
end if | |
tell application "System Events" | |
set frontmost of process "Finder" to true | |
end tell | |
delay 1 | |
tell application "Finder" | |
set sel to the selection | |
set countsel to count sel | |
set m1 to modification date of last item of sel | |
set lastitem to last item of sel | |
end tell | |
delay 0.5 | |
if countsel is less than 50 then | |
set sdelay to 2 | |
end if | |
if countsel is greater than 49 and countsel is less than 100 then | |
set sdelay to 4 | |
end if | |
if countsel is greater than 99 and countsel is less than 150 then | |
set sdelay to 6 | |
end if | |
if countsel is greater than 149 then | |
set sdelay to 8 | |
end if | |
tell application "System Events" to keystroke "o" using {command down} | |
delay 2 | |
tell application "System Events" | |
key code 36 | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
end tell | |
repeat until activeApp is "Preview" | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
end tell | |
delay 0.5 | |
end repeat | |
delay 2 | |
tell application "System Events" | |
set frontmost of process "Preview" to true | |
end tell | |
delay sdelay | |
tell application "System Events" | |
keystroke "a" using {command down} | |
end tell | |
delay 2 | |
tell application "System Events" | |
tell process "Preview" | |
click menu "Tools" of menu bar 1 | |
end tell | |
end tell | |
delay 2 | |
tell application "System Events" | |
repeat 4 times | |
key code 125 | |
delay 0.2 | |
end repeat | |
delay 0.5 | |
key code 36 | |
delay 2 | |
key code 48 | |
delay 0.2 | |
key code 48 | |
delay 0.2 | |
key code 48 | |
delay 0.2 | |
keystroke resolution | |
delay 0.5 | |
key code 36 | |
end tell | |
delay 2 | |
tell application "System Events" | |
set frontmost of process "Preview" to true | |
delay 0.5 | |
keystroke "w" using {command down} | |
end tell | |
tell application "Finder" | |
set m2 to modification date of lastitem | |
end tell | |
repeat until m1 is not m2 | |
tell application "Finder" | |
set m2 to modification date of lastitem | |
delay 3 | |
end tell | |
end repeat | |
delay 0.1 | |
if prun is 0 then | |
tell application "Preview" | |
quit | |
end tell | |
end if | |
tell application "System Events" | |
display notification "Done!" with title "Script 56" | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment