如何隐藏当前活动的NSWindow A 并关注最后一个 B (当前窗口后一级)并将其激活?
我尝试使用此跟踪代码,但它不起作用( B 将变为前窗但未激活):
[_parentWindow orderBack:nil];
// Now i want to do some stuffs with last opened App (NSWindow) and it should be focused and activated now.
[_parentWindow orderFront:nil];
答案 0 :(得分:0)
请尝试makeKeyAndOrderFront:
。
[_window makeKeyAndOrderFront:nil];
答案 1 :(得分:0)
@bluedome响应的补充。您可以在当前用户会话中获取有关Windows的信息:
CFArrayRef windowList = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
for (NSDictionary* entry in (__bridge NSArray *)windowList) {
NSString *ownerName = [entry objectForKey:(id)kCGWindowOwnerName];
NSInteger ownerPID = [[entry objectForKey:(id)kCGWindowOwnerPID] integerValue];
NSString *windowName = [entry objectForKey:(id)kCGWindowName];
NSLog(@"%@:%ld, %@", ownerName, (long)ownerPID, windowName);
}