I don't know code which is really embarrassing for simple tasks like this one. All I'm trying to do is to make a Quick Action in Automator for this:
- take a screenshot based on two fixed points
- click a "next" button in an app (in my case; Kindle for Mac)
- Repeat X times
Caveat (if relevant): my screenshots capture in JPG format (not PNG).
Though my "watch me do" was not successful, the recording process did capture me depressing the app's page-advance button which I see is called "Next Page."
A workaround would be to use CliClick to push the advance button, if which I already have installed if "Next Page" might not work for whatever reason. The repeating screenshot would be a pre-defined pair of coordinates based on upper-left and lower-right (which I can get via CMD+SHIFT+4).
Thanks so much in advance! Any method to pull this off in Automator is fine by me. Cheers!
EDIT 1: added code for @ankii below here
EDIT 2: deleted what was added in EDIT 1 (no longer relevant)
Best Answer
Kindle is not AppleScript scriptable in that it does not contain an AppleScript dictionary within its application bundle; however it is, within limits, using System Events and UI Scripting. Note though that with UI Scripting one must not use the system for other things while the script is running as Kindle needs to remain frontmost while the script is running.
The following example AppleScript code, tested under macOS High Sierra took screen shots of the first 5 pages of the BASH Reference Manual:
Note: The example AppleScript code is just that and does not contain any error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g.
delay 0.5
, with the value of the delay set appropriately.