Skip to content

Instantly share code, notes, and snippets.

@tburgin
Last active March 17, 2018 20:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tburgin/945b93dd85b9b96ba8c97a480ea6ab49 to your computer and use it in GitHub Desktop.
Save tburgin/945b93dd85b9b96ba8c97a480ea6ab49 to your computer and use it in GitHub Desktop.
from AppKit import NSRunningApplication
print NSRunningApplication.runningApplicationsWithBundleIdentifier_("com.google.Chrome").count()
#import <AppKit/AppKit.h>
int main(int argc, char *argv[]) {
@autoreleasepool {
[[NSWorkspace sharedWorkspace] openURLs:@[ [NSURL URLWithString:@"chrome://restart"] ]
withAppBundleIdentifier:@"com.google.Chrome"
options:NSWorkspaceLaunchWithoutActivation
additionalEventParamDescriptor:nil
launchIdentifiers:NULL];
}
}
from AppKit import NSWorkspace
from AppKit import NSWorkspaceLaunchWithoutActivation
from Foundation import NSURL
URL = NSURL.URLWithString_("chrome://restart")
workspace = NSWorkspace.sharedWorkspace()
workspace.openURLs_withAppBundleIdentifier_options_additionalEventParamDescriptor_launchIdentifiers_([URL], "com.google.Chrome", NSWorkspaceLaunchWithoutActivation, None, None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment