11globalForegroundWindow
Version 2022/03/10
Created 2021/06/17
Category Max/Msp Externals
ZipSize 97.44 KB
Downloads 1,865
Description:

Get and set the SYSTEM-WIDE foreground app / window.

The goal here was to be able to switch to another application without user interaction. Then I added some extra features and explored what is possible if we want to remain cross-platform compatible.

Without any further action on Mac, we can get, set and quit the active app. I called that "basic" functionality. If the Accessibility Api gets enabled for Max (or the app running the external), we can do some more stuff. You will see that in the help patcher tab "advanced". On Windows(OS) there are no restrictions on using "advanced" features.

You have to be careful how and where you use it. Setting the focus to another application is normally only expected to be done manually by the user.    

Pics:
11globalForgroundWindow_basic.maxhelp 11globalForgroundWindow_advanced.maxhelp2
Changelog:

2022/03/10

  • added method to check if an app is running

2022/01/30

  • updated main method

2022/01/18

  • supports Apple Silicon
Discussion:

https://cycling74.com/forums/is-a-specific-external-application-already-running/