having max be the foremost app on startup

John Morton's icon

Hello - I am running an installation that needs to have Max be the foremost app on startup.

When the computer shuts down and starts up again (daily),  the max patch reloads normally.  However, the desktop is still on the Finder window, not on Max.  Thus, when the activation switch for the installation is depressed, it doesn't register on the max window.  It won't work until I physically click the cursor on the max patch. And I am not at the location to do that.

Is there a way to make sure that the Max window is foremost on the desktop when restarting? Does anyone have an automator sequence that would do this, or can guide me with the steps necessary to accomplish this? Many thanks-

John


Source Audio's icon

how do you start max -> patch on boot ?

If using scripting, it should be no problem to boot and activate Max with

specified patch.

Better would be to use standalone.app

Another question is what is that activation switch for the installation ?

whay should it not work if max is in the background ?

Only explanation would be if it listens to keystrokes,

and if you are not there to click on may window,¨how do you send keystrokes ?

Andy Maskell's icon

You might want to take a look at 11Olsen's 11GlobalForgroundWindow external if you can find a copy but I see that 11Olsen is no longer publishing or supporting his routines.

You can probably do what you need with the following:

Depending what is also going on at Startup, you might need to add a delay or use another means to trigger the (front) message to [thispatcher].

John Morton's icon

The patch is started with an external button (actually, a stenographer foot pedal that activates the key B when depressed). But if the patch isn't on the foreground, it will be ignored. Once I manually press the cursor on the max patch (thus bringing the max window to the forefront), it works perfectly.

Source Audio's icon

so you use wrong kind of switch.

if it was anything like midi, hid device etc it would not matter

if max is in focus or not.

but I asked what do you use to start max and patch in first place ?

if it was applescript app

using something like

delay 2

tell application "Max" to open "/Users/Mac/Desktop/Test.maxpat"

then max should start, open that patch and sit in front

P.S.

that foot Pedal is probably HID compliant.

One could capture it using hi object in Max

which works no matter if Max is frontmost app.

It will output a series of numbers,

maybe you need to insert print to see it completelly

and so decipher it as needed switch.

If you need a help with that, just post

Roman Thilenius's icon

in my extraordinary operating system i also have a similar problem when i need to run max patches headless. they are not depending on the "active" situation, it is just so, that starting a max patch from the auto startup folder (of the OS) opens max - but not always the patch.

i temporarily solved that by simply adding another round of launching the same patch once more, after a longer delay (within in the same applescript.)

the same should solve your issue, too.


i see that loadbang-"front" has already been mentioned above. another idea could be to open that patch using pcontrol.

one requirement is of couse that other currently open patches do not do the same.

John Morton's icon

So I was able to solve things. For the first time, AI came through for me. I did a search for "bring a max patch forefront when starting Mac mini" and AI spit out this code along with export/login instructions:

-- Replace with the actual path to your Max/MSP patch file

set thePatchPath to POSIX file "/ICloudDrive/Documents/Max8/Projects/MinisceongoOverlay/MinisceongoOverlay.maxproj"

-- Define the application

set maxApp to "Max"

-- Tell Max to activate and open the patch

tell application maxApp

-- This 'activate' command brings the application to the foreground

activate

open thePatchPath

end tell

The only thing I needed to do was enter the pathway for the patch, export it as an app and add it to the login.

Never used AppleScript before, so this was an incredible assist. A bit terrifying, however.

Thanks everyone for their suggestions!

Source Audio's icon

Keeping specific patch in max on top is a different problem.

Doing anything unattended in Max itself will not set it to fronmost app.

unless you use shell to osascript Max back to front

you can forget any messages like front to thispatcher and similar.

If you tell Max to open a patch 2 times, you will end

with 2 patchers open, or as many as you called ...

back to Max as front app, using repeat like this will loop forever using

set delay time only to activate Max, not to open patch again

and then there is this max-startup folder in resources/C74 :

put a patch there and Max will load it on startup.