Last active
February 24, 2016 17:38
-
-
Save nomeyer/6a8c89e03290bbc5b673 to your computer and use it in GitHub Desktop.
Get the PID of the frontmost app on Mac OS X
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
#import <AppKit/AppKit.h> | |
NSRunningApplication* frontApp = [[NSWorkspace sharedWorkspace] frontmostApplication]; | |
pid_t pid = [frontApp processIdentifier]; | |
// fprintf(stdout, "%s\n", [[NSString stringWithFormat:@"%ld", (long)pid] UTF8String]); | |
// fflush(stdout); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment