Skip to content

Instantly share code, notes, and snippets.

@TatsuyaOGth
Created January 2, 2015 19:28
Show Gist options
  • Save TatsuyaOGth/d7855651a0f2ed458a50 to your computer and use it in GitHub Desktop.
Save TatsuyaOGth/d7855651a0f2ed458a50 to your computer and use it in GitHub Desktop.
Automatic Screen Logger Python code for Mac OSX
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import time
import subprocess
from datetime import datetime
argv = sys.argv
if len(argv) > 1:
interval_sec = int(argv[1])
else:
interval_sec = 60*5
img_format = 'png'
savepath = '~/Pictures/Screenshot/'
prepend_filename = 'log'
print '[[[ START AUTO SCREEN LOGGER ]]]'
print '- INTERVAL : ' + str(interval_sec) + 'sec'
print '- SAVE PATH : ' + savepath
print '- FORMAT : ' + img_format
print '- FILENAME : ' + prepend_filename + '_[TIMESTAMP].[FORMAT]'
print 'kill command : \'[cmd]+c\''
while True:
ts = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
cmd = 'screencapture -x -t '+img_format+' '+savepath+prepend_filename+'_'+ts+'.'+img_format
print cmd
subprocess.call(cmd, shell=True)
time.sleep(interval_sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment