is there any way on Mac OS to detect which application or process currently has got the focus?
I didn’t get any results from google.
AppleScript seems able to do so, but this may be off limit in the MAS.
The way this used to be done was using NSWorkspace but I’m not sure anything like this would fly on the Mac App Store anymore.
I agree with @Michel Bujardet , lots of things that used to be okay are no longer acceptable in this security and privacy-conscious age. AppleScript used to have free rein over the OS and running apps but I wouldn’t be planning a new app around it these days.
I don’t know the MAS implications of this, but IF you enable some macOS Accessibility settings you can glean a bunch of information from AccessibilityMBS . At the bottom of that page are links to some sample code which may help determine if suitable.
However, I think it does require a user to have Accessibility enabled, and I don’t know the implications for MAS or similar.