Skip to content

Instantly share code, notes, and snippets.

@iWindmill
Created September 6, 2024 18:15
Show Gist options
  • Save iWindmill/190637488fd6048cc5da1ff8daac7033 to your computer and use it in GitHub Desktop.
Save iWindmill/190637488fd6048cc5da1ff8daac7033 to your computer and use it in GitHub Desktop.
A small AppleScript to take a screenshot every 60 seconds. Saves images with the active application name and window title. Great for recording your workday for self-organization purposes.
-- Thank you, jonobr1 https://gist.github.com/jonobr1/a91c166a94a65e64c9b7
set dFolder to "~/Desktop/screencapture/"
do shell script ("mkdir -p " & dFolder)
global frontApp, frontAppName, windowTitle
set i to 0
repeat 1440 times
tell application "System Events"
set frontApp to first application process whose frontmost is true
set frontAppName to name of frontApp
tell process frontAppName
tell (1st window whose value of attribute "AXMain" is true)
set windowTitle to value of attribute "AXTitle"
end tell
end tell
end tell
set frontAppName to frontAppName
set frontAppName to do shell script "echo " & quoted form of frontAppName & " | sed -e 's|[^a-zA-Z0-9]||g'"
set windowTitle to windowTitle
set windowTitle to do shell script "echo " & quoted form of windowTitle & " | sed -e 's|[^a-zA-Z0-9]||g'"
set dateString to do shell script "date +'%Y.%m.%d.%k%M'"
do shell script ("screencapture -D 1 " & dFolder & "Screenshot,\\ " & frontAppName & ",\\ " & windowTitle & ",\\ " & dateString & ".png")
delay 60 -- Wait for 60 seconds.
set i to i + 1
end repeat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment