How to programmatically make cocoa application active

后端 未结 3 1044
傲寒
傲寒 2020-12-14 08:05

I\'ve got a background process that makes a transparent window appear when a hotkey is pressed:

[window makeKeyAndOrderFront:nil];
[[content animator] setAlp         


        
相关标签:
3条回答
  • 2020-12-14 08:43

    For 10.6 or greater

    [[NSRunningApplication currentApplication] activateWithOptions:(NSApplicationActivateAllWindows | NSApplicationActivateIgnoringOtherApps)];
    
    0 讨论(0)
  • 2020-12-14 08:48

    Look at [[NSApplication sharedApplication] activateIgnoringOtherApps : YES];.

    0 讨论(0)
  • 2020-12-14 08:53

    Swift 4.2+ of @Arvin answer

    NSRunningApplication.current.activate(options: [.activateIgnoringOtherApps, .activateAllWindows])
    
    0 讨论(0)
提交回复
热议问题