开发者

background cocoa app/utility that displays full screen image at given time

I want to write an app for Mac OS X. The app/utility would ac开发者_如何学运维t according to preset schedule. I will have different time intervals at which I want this app to show a certain image in full screen regarding if there are other apps running at the time.

The real question is how to check this time interval in the background and bring this app in-front and enter full screen. I know how to go full screen, but I am stuck at bringing this app in-front of all other apps.


To schedule a method to be called after an interval, just use NSTimer and one of its +scheduledTimer... methods.

To force your application to be active, call [NSApp activateIgnoringOtherApps:YES].

If you want your window to appear above absolutely everything, including the screensaver, set its level to NSScreenSaverWindowLevel + 1.


The only solution that comes immediately to mind is use AppleScript, e.g. if you execute the following AppleScript from within your app:

tell application "MyBackgroundApp"
  activate
end tell

There is an Apple Tech Note with sample code for sending AppleScript from a Cocoa app using NSAppleScript.


How to force Mac window to foreground?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜