Advertisement
Guest User

Untitled

a guest
May 20th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. from AppKit import NSWorkspace
  2. import time
  3. from datetime import datetime
  4.  
  5. date = str(datetime.now().date())
  6. apptimes = {}
  7.  
  8. try:
  9. while True:
  10. app = NSWorkspace.sharedWorkspace().activeApplication()['NSApplicationName']
  11. apptimes[app] = apptimes.get(app, 0) + 1
  12. time.sleep(1)
  13. finally:
  14. filename = date + ".txt"
  15. f = open("/Users/me/Library/AppTimes/" + filename, 'w+')
  16. f.write(str(apptimes))
  17. f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement