Skip to content

Instantly share code, notes, and snippets.

@xoxwgys56
Created December 2, 2021 01:14
Show Gist options
  • Save xoxwgys56/4638a0f363bd87b5579029796481f869 to your computer and use it in GitHub Desktop.
Save xoxwgys56/4638a0f363bd87b5579029796481f869 to your computer and use it in GitHub Desktop.
ebook screen capture
# init for loop
set idx to 0 as number
set maxRange to 110 as number
# init environment value
set basePath to "~/local/screenshots"
set srcPath to basePath & "/temp" as string
set destPath to basePath & "/result" as string
do shell script "mkdir -p " & srcPath
do shell script "mkdir -p " & destPath
set applicationName to "AppName"
set {year:y, month:m, day:d} to (current date)
set today to (y & m & d) as string
set LeftArrowKey to 123
# focus application for screenshot
tell application applicationName
activate
delay 1
end tell
repeat while (idx) is less than (maxRange)
set curIdx to idx
text -4 thru -1 of ("0000" & curIdx)
set fileName to (today & "-" as string) & curIdx as string
set filePath to srcPath & ("/" as string) & fileName & ".png" as string
# do screenshot
do shell script "screencapture -m " & filePath
tell application applicationName
activate
end tell
tell application "System Events"
key code LeftArrowKey
delay 0.5
end tell
# increment
set idx to idx + 1
end repeat
@xoxwgys56
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment