#!/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"