Skip to content

Instantly share code, notes, and snippets.

@ccgus
Created October 27, 2017 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ccgus/7903cfd19605d1399f9cd8bc9d413d37 to your computer and use it in GitHub Desktop.
Save ccgus/7903cfd19605d1399f9cd8bc9d413d37 to your computer and use it in GitHub Desktop.
NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
NSDictionary *activeAppDict = [workspace activeApplication];
ProcessSerialNumber psn;
psn.highLongOfPSN = [[activeAppDict objectForKey:@"NSApplicationProcessSerialNumberHigh"] intValue];
psn.lowLongOfPSN = [[activeAppDict objectForKey:@"NSApplicationProcessSerialNumberLow"] intValue];
SetFrontProcess( &psn );
// this .. causes a bit o' recursion for some reason.
//ProcessSerialNumber xpsn = { 0, kCurrentProcess };
//SetFrontProcess( & xpsn );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment