Note that there are some explanatory texts on larger screens.

plurals
  1. POActivity monitor not responding
    primarykey
    data
    text
    <p>when i'm calling the below function in a time interval of 1 second, it would cause Not Responding in Activity Monitor, anyone can tell me why and suggest a solution?</p> <pre><code>NSWorkspace* workspace = [NSWorkspace sharedWorkspace]; NSDictionary* currentAppInfo = [workspace activeApplication]; //get the PSN of the current app UInt32 lowLong = [[currentAppInfo objectForKey:@"NSApplicationProcessSerialNumberLow"] longValue]; UInt32 highLong = [[currentAppInfo objectForKey:@"NSApplicationProcessSerialNumberHigh"] longValue]; ProcessSerialNumber currentAppPSN = {highLong,lowLong}; //grab window information from the window server CFArrayRef windowList = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly, kCGNullWindowID); ProcessSerialNumber myPSN = {kNoProcess, kNoProcess}; //loop through the windows, the window list is ordered from front to back for (NSMutableDictionary* entry in (NSArray*) windowList) { int pid = [[entry objectForKey:(id)kCGWindowOwnerPID] intValue]; GetProcessForPID(pid, &amp;myPSN); //if the process of the current window in the list matches our process, get the front window number if(myPSN.lowLongOfPSN == currentAppPSN.lowLongOfPSN &amp;&amp; myPSN.highLongOfPSN == currentAppPSN.highLongOfPSN) { NSNumber* windowNumber = [entry objectForKey:(id)kCGWindowNumber]; NSString* applicationName = [entry objectForKey:(id)kCGWindowOwnerName]; NSLog(@"The current app is %@ and the window number of its front window is %@.",applicationName,windowNumber); //break because we only want the front window break; } } CFRelease(windowList); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload