Facebook
From Corrupt Pintail, 3 Years ago, written in Python.
Embed
Download Paste or View Raw
Hits: 728
  1. #!/usr/bin/python
  2. try:
  3.     from AppKit import NSWorkspace
  4. except ImportError:
  5.     print "Can't import AppKit -- maybe you're running python from brew?"
  6.     print "Try running with Apple's /usr/bin/python instead."
  7.     exit(1)
  8.  
  9. from datetime import datetime
  10. from time import sleep
  11.  
  12. last_active_name = None
  13. while True:
  14.     active_app = NSWorkspace.sharedWorkspace().activeApplication()
  15.     if active_app['NSApplicationName'] != last_active_name:
  16.         last_active_name = active_app['NSApplicationName']
  17.         print '%s: %s [%s]' % (
  18.             datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
  19.             active_app['NSApplicationName'],
  20.             active_app['NSApplicationPath']
  21.         )
  22.     sleep(1)

Replies to Untitled rss

Title Name Language When
Re: Untitled Commodious Zebra python 1 Year ago.