Maybe an odd question but I need a way to check if my app is active or not?
I would add a timer that checks at interval x if my app is the active app. So when another app is active by the user, it should return false.
My guess is that Michel needs applause for every reply he gives. Otherwise you step on his Hobbit feet (read: long toes). (*) @Michel … thats humour, in case you did not catch that.
In fact, the solution Christian gave doesn’t work when you have a window that is Global Floating. app.frontMostMBS always returns True in that case.
So the problem remains. This is really a very hard to find problem.
Checking if the app is active (not just front most app) seems not very difficult.
[quote=334065:@Christoph De Vocht]@Eli. Unfortunately this doesn’t work when the app has a Global Floating window. The events App.Activate is not triggered.
Will checkout the NSApplicationMBS too.[/quote]
Seems like the global floating window may be causing a problem as it may be constantly telling the app that it is in the foreground; at which point I would suggest asking the OS for the foremost application and comparing that bundle identifier with yours.
Ah, maybe you mean when the Global Floating Window is activated? Then it is not called. But that this correct, as the application is still not activated. For that use the Global Floating Window’s Activate event. So in your case you need to monitor both events (App.Activate and GlobalFloatingWindow1.Activate).
I made a new small app and it works indeed. For some case it doesn’t in my app. Maybe because the Global Floating window is only shown in full screen. Not sure.