ambiguous process name

Hi:

I have a simple script to bring a window to the front. The program is called Finale. However, the name could be 7 different titles (FInale 2007, Finale, 2008, etc.) depending on which version the user has installed.

My code is:


tell application "System Events"
	tell process "Finale 2012"
		set frontmost to true
	end tell
end tell

As opposed to Autohotkey for Windows, I have to be specific here as to the ‘exact’ name (AHK, I could just do something like, WinActivate, Finale, and it would get it regardless of the year). I suppose I could use error handling to try each one, but something tells me it’s easier than that…

Hello.

Hopefully the code below works. “sevs” is an app identifier for System Events. I have also embellished the code in a try block, for the case that the Finale app isn’t running at the moment the script executes, otherwise, a run time error will occur.

tell application id "sevs"
	try
		set finaleName to name of first process whose name begins with "Finale"
		tell process finaleName to set frontmost to true
	end try
end tell

Hi,

I had the same problem while writing a print manager for Finale.
I’m using this, however it works only for the versions since Finale has been sold to MakeMusic.

The solution of McUsr is fine, too


set finaleName to finaleProcessName()

on finaleProcessName()
	tell application "System Events"
		try
			set finaleProcess to 1st process whose bundle identifier contains "makemusic"
			return name of finaleProcess
		on error
			return missing value
		end try
	end tell
end finaleProcessName

Great solutions. Thanks guys.