I want to open an image on the desktop with the 'Quick Look', then screenshot it, and then open the new screenshot to take another one of it. In resume, I want to know how to screenshot an image that has just been screenshoted, endlessly. How can I do it on AppleScript?
I know it sounds kind of weird, but its for artistic purposes. The resultant image is a feedback of the image itself being screenshoted. Also, it is important that the image is being opened as 'quick look' because it displays the top bar with the date and time of the screenshot, so the feedback is clear. Thank you so much.
(This image is a reference I made myself with this intention. Is exactly what I'm trying to automate]1]1
//The script I've accomplished by now is:
tell application "Finder"
do shell script "qlmanage - p /cm.jpg"
set dFolder to "~/Desktop/screencapture/"
do shell script ("mkdir -p " & dFolder)
set i to 0
repeat 960 times
set tTime to do shell script "date +%H%M%S"
do shell script ("screencapture " & dFolder & "frame-" & i & ".png")
delay 5
set i to i + 1
end repeat
end tell
// I still don't know how to make it work related to a specific image, and then related to each new screenshot.
Best Answer
As with any script that tries to control the UI, this script is brittle and relies on sufficient delays to give the Quick Look window time to form and the image to be painted. Although the script does check for the window's existence, it cannot check to make sure that the contents of the window has been painted, so I have had variable results in testing, including some good successes:
You must ensure the necessary accessibility privileges are granted for this script to run.
Note: This script was written and tested using AppleScript version: 2.7 System version: 10.13.6