I need to display a modal dialog on the main/frontmost window even if that window is not mine(i.e. the client may be watching a video in fullscreen on Chrome). How can I do that? Currently I'm testing by setting a delay and working in a different app which doesn't work(i.e. the alert is visible only when I switch to the application). I'm looking to develop a kind of system wide plugin thus the reason it needs to be global.
Additional Details: I don't want to move the focus away from the frontmost application. I need something like the UserNotification but with more control over the UI. The user will actually activate the "menu" using a keyboard shortcut.
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(10), execute: {
// Insert code here to initialize your application
let alert = NSAlert.init()
alert.messageText = "Hello world"
alert.informativeText = "Information text"
alert.addButton(withTitle: "OK")
alert.addButton(withTitle: "Cancel")
alert.runModal()
// Put your code which should be executed with a delay here
})