如何激活已最小化的其他应用程序的窗口?
如果前面有其他窗口,它可以很好地使用NSRunningApplication类的activateWithOptions方法,但是这不能用于最小化窗口。
如果你能够帮助我,那就太好了。
干杯
答案 0 :(得分:1)
试图摆弄AppleEvents&想出了这个:
//Get the PID for a running application.
NSRunningApplication* runningApp = [[NSRunningApplication
runningApplicationsWithBundleIdentifier:@"com.apple.Safari"]
lastObject];
pid_t appPID = [runningApp processIdentifier];
//Create event target.
NSAppleEventDescriptor* targetDescriptor
= [NSAppleEventDescriptor descriptorWithDescriptorType:typeKernelProcessID
bytes:&appPID
length:sizeof(appPID)];
//Create "reopen" event.
NSAppleEventDescriptor* reopenDescriptor
= [NSAppleEventDescriptor appleEventWithEventClass:kCoreEventClass
eventID:kAEReopenApplication
targetDescriptor:targetDescriptor
returnID:kAutoGenerateReturnID
transactionID:kAnyTransactionID];
//Create "activate" event.
NSAppleEventDescriptor* activateDescriptor
= [NSAppleEventDescriptor appleEventWithEventClass:kAEMiscStandards
eventID:kAEActivate
targetDescriptor:targetDescriptor
returnID:kAutoGenerateReturnID
transactionID:kAnyTransactionID];
//Send "activate" followed by "reopen".
AESendMessage([activateDescriptor aeDesc], NULL, kAENoReply, kAEDefaultTimeout);
AESendMessage([reopenDescriptor aeDesc], NULL, kAENoReply, kAEDefaultTimeout);
可能有更好的方法,但它有效。
答案 1 :(得分:0)