Skip to content

Instantly share code, notes, and snippets.

@2shortplanks
Created May 14, 2024 06:37
Show Gist options
  • Save 2shortplanks/aebd76f48adb3eb583504add2ba8e5db to your computer and use it in GitHub Desktop.
Save 2shortplanks/aebd76f48adb3eb583504add2ba8e5db to your computer and use it in GitHub Desktop.
Capture an entire Slack Channel as screenshots
set epoch to do shell script "perl -e 'print ~~time'"
set dir to "/tmp/" & epoch
do shell script "mkdir " & dir
tell application "Slack" to activate
tell application "System Events"
set counter to 1
repeat 1000 times
delay 1
set activeApp to name of first application process whose frontmost is true
set winSize to size of window 1 of application process activeApp
set winPos to position of window 1 of application process activeApp
do shell script "screencapture -x -R" & item 1 of winPos & "," & item 2 of winPos & "," & item 1 of winSize & "," & item 2 of winSize & " " & dir & "/screenshot-" & counter & ".png"
try
do shell script "(! cmp -s " & dir & "/screenshot-" & counter & ".png " & dir & "/screenshot-" & (counter - 1) & ".png)"
on error
display dialog "Done!"
return
end try
set counter to counter + 1
delay 1
key code 116
delay 1
key code 125
end repeat
end tell
@2shortplanks
Copy link
Author

You'll need to enable the ability for Script Editor to capture the screen and act as an assistive device in order for this to work.

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