Created
January 14, 2014 18:00
-
-
Save eahrold/8422737 to your computer and use it in GitHub Desktop.
close a running application with python and NSWorkspace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from AppKit import NSWorkspace | |
def closeRunningApplication(bundle_id): | |
ws = NSWorkspace.sharedWorkspace() | |
runningApps = ws.runningApplications() | |
for i in runningApps: | |
if i.bundleIdentifier() == bundle_id: | |
i.terminate() | |
def main(): | |
closeRunningApplication('app.bundle.id') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
python close_app.py