Is external application already running? And bring its window to front!

    MaxMSPadvancedresolved

    Andy Maskell's icon
    Andy Maskell's icon
    Andy Maskell
    Mar 04 2022 | 4:53 pm
    I know I've seen something about this before but I'm blowed if I can find from a search!
    How can I test to see if another application I need to interface to is already running? I'm using Windows 10 and I need to find out if CuBase is already running or not when I launch my project.
    Ideally, I'd also like to bring it's window into the forground.
    Any ideas would be welcome!

    • 11olsen's icon
      11olsen's icon
      11olsen
      Mar 05 2022 | 10:32 am
      Max Patcher
      In Max, select New From Clipboard.
      Show Text
      the external is on my page.
      Share
    • Andy Maskell's icon
      Andy Maskell's icon
      Andy Maskell
      Mar 05 2022 | 11:03 am
      Thank you. It would be perfect I suspect but I'm running Windows and your external is only compiled for Mac.
    • 11olsen's icon
      11olsen's icon
      11olsen
      Mar 05 2022 | 11:14 am
      nope. mxe64 is the Win external (64bit)
    • Andy Maskell's icon
      Andy Maskell's icon
      Andy Maskell
      Mar 05 2022 | 11:49 am
      I must be looking in the wrong place then as the zip that I've downloaded only has the Mac version.
    • 11olsen's icon
      11olsen's icon
      11olsen
      Mar 05 2022 | 11:54 am
      Ok. You went here? Zip seem to be complete.
    • Andy Maskell's icon
      Andy Maskell's icon
      Andy Maskell
      Mar 05 2022 | 12:03 pm
      Yes,I've got a download with the mxe64 in now. So where do I put it? Haha!
    • Andy Maskell's icon
      Andy Maskell's icon
      Andy Maskell
      Mar 05 2022 | 12:11 pm
      I've put the folder in my Documents/Max 8/Packages folder and the Package Manager lists it as installed but when I load your patch the Console says the 11globalForegroundWindow object is unknown!
    • 11olsen's icon
      11olsen's icon
      11olsen
      Mar 05 2022 | 12:23 pm
      Create a folder where you put all 3rd party externals. Add that folder to Max searchpath (Options->File Preferences). Or save externals in a Folder which is in the searchpatch by default. for example: C:/Users/<name>/Documents/Max 8/Library/
    • Andy Maskell's icon
      Andy Maskell's icon
      Andy Maskell
      Mar 05 2022 | 12:28 pm
      Cracked it! Brilliant! Thank you so much.
    • Andy Maskell's icon
      Andy Maskell's icon
      Andy Maskell
      Mar 07 2022 | 3:04 pm
      Just to let you know that I've used your 11globalForegroundWindow with an error trap as you suggested and it works absolutely brilliantly with Cubase and Mixing-Station, the two apps that I'm interfacing to. I can now switch between apps as I change the data feed for my console and my project now automatically clears the memory recall store and reloads the apps if they have been closed and/or crashed. Totally brilliant solution for my needs! Thank you.
      For clarity, the connector colours are: White: initialisation routine (from loadbang) Bright red: data switching routine Dark red: Cubase Green: Mixing-Station Black: error handling Red objects: links to the memory bank for each app configuration
    • 11olsen's icon
      11olsen's icon
      11olsen
      Mar 09 2022 | 3:09 pm
      I'm glad that it's useful. I think i will add a message to the object to check if an app is running. Seems more elegant than catching the error. Also error messages are not equal on Win and Mac versions. it's on my todo list.
    • Andy Maskell's icon
      Andy Maskell's icon
      Andy Maskell
      Mar 09 2022 | 4:21 pm
      Thank you. I'd be happy to test it for you if you do although I'm only Windows based, as much as I'd prefer to be running a Mac!!! I've credited you for use of the routine in my patch. Do you have an "official" copyright notice and a donations page?
    • 11olsen's icon
      11olsen's icon
      11olsen
      Mar 10 2022 | 5:38 pm
      I added a message "isrunning <appname>" to do the check. I have my tag in the console. No donations page atm but nice of you to ask ;)
    • Andy Maskell's icon
      Andy Maskell's icon
      Andy Maskell
      Mar 10 2022 | 5:41 pm
      Ok. I'll try the new version and report back. The tag in the console is what I had used to credit you thus far.
    • Andy Maskell's icon
      Andy Maskell's icon
      Andy Maskell
      Mar 10 2022 | 7:03 pm
      Hey! Yes, it works! I'll have to rework my logic a bit to use the isrunning message though.
    • 11olsen's icon
      11olsen's icon
      11olsen
      Mar 10 2022 | 7:13 pm
      There's nothing wrong with the error catching way but it's good to have a separat message to do the check without setting the focus.
    • Andy Maskell's icon
      Andy Maskell's icon
      Andy Maskell
      Mar 10 2022 | 9:22 pm
      The only problem with the error method is that it will be triggered by any error, albeit with the ability to filter out the ones that matter. I’ve rewritten my patch to use the isrunning method and it works a treat:
      Thank you.