How to detect that an application (e.g. Quicktime) prevents the startup screen saver

I want my application to not do certain things when the user watches a movie, starts a slide show or performs any other action when the machine is actively used, but the mouse and keyboard do not work.

I know that calling UpdateSystemActivity() every 30 seconds prevents the screensaver from starting, but I am wondering if there is a way to detect that the screensaver is not working or not.

It must be safe on the App Store.

+4
source share
1 answer

My notes say that there is a way to do this using an undocumented class, ScreenSaverController . Here is the title:

 @interface ScreenSaverController : NSObject { void *_reserved; } + (id)controller; + (id)enginePath; - (id)init; - (void)dealloc; - (BOOL)screenSaverIsRunning; - (BOOL)screenSaverCanRun; - (void)setScreenSaverCanRun:(BOOL)arg1; - (void)screenSaverStartNow; - (void)screenSaverStopNow; - (void)restartForUser:(id)arg1; - (double)screenSaverTimeRemaining; - (BOOL)screenSaverIsRunningInBackground; - (void)screenSaverDidFadeInBackground:(BOOL)arg1 psnHi:(unsigned int)arg2 psnLow:(unsigned int)arg3; @end 

And here is how to use it:

 ScreenSaverController *ssc = [ScreenSaverController controller]; if ([ssc screenSaverCanRun]) { ... } [ssc release]; 

Note that to use it, you will need to bind the ScreenSaver structure. Since this is an undocumented class, this will make your application inappropriate for the Mac App Store.

Also take a look at screenSaverTimeRemaining - some ways to prevent the splash screen from starting may just be reset.

+1
source

Source: https://habr.com/ru/post/1401708/


All Articles