Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from AppKit import NSWorkspace
- import time
- from datetime import datetime
- date = str(datetime.now().date())
- apptimes = {}
- try:
- while True:
- app = NSWorkspace.sharedWorkspace().activeApplication()['NSApplicationName']
- apptimes[app] = apptimes.get(app, 0) + 1
- time.sleep(1)
- finally:
- filename = date + ".txt"
- f = open("/Users/me/Library/AppTimes/" + filename, 'w+')
- f.write(str(apptimes))
- f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement