Skip to content

Instantly share code, notes, and snippets.

@kyanny
Created July 28, 2022 14:38
Show Gist options
  • Save kyanny/5d6d2c286528ec6860e340d0f80f8760 to your computer and use it in GitHub Desktop.
Save kyanny/5d6d2c286528ec6860e340d0f80f8760 to your computer and use it in GitHub Desktop.
#!/bin/bash
UUID=$(uuidgen)
WORKDIR="$HOME/Desktop/$UUID"
mkdir -p "$WORKDIR"
osascript -e 'activate application "Slack"'
sleep 0.5
i=0
while true
do
i=$(printf "%.3d" $i)
filename=$(printf "%.3d.png" $i)
screencapture -o "$WORKDIR/$filename"
i=$((i + 1))
# display dialog
# if "Cancel" is clicked or ESC key is pressed, the following `osascript` command exits with status code 1 (error).
# if "OK" is clicked or RETURN key is pressed, the following `osascript` command exits with status code 0 (success).
if osascript -e 'display dialog "Continue taking screenshot?" default button "OK"' 1>/dev/null 2>/dev/null
then
osascript -e 'activate application "Slack"'
osascript -e 'tell application "System Events" to key code 121' # page down
sleep 0.5
else
break
fi
done
osascript -e "display notification \"It will open the working folder $WORKDIR soon.\" with title \"Concatenating screenshots\""
convert -append "$WORKDIR/*.png" "$WORKDIR/out.png"
open "$WORKDIR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment