Giving Focus to Automator Application

I’m a perennial beginner with Automator and AppleScript. I created an application that, when launched, shows a list (via Applescript within Automator) from which the user chooses one item.

That list does not have the focus by default, so I added “tell application…activate” at the front to give it the focus. However, I hard-coded the application name because I don’t know how to provide the application name programmatically. Can somebody please teach me how?

Here is a stripped-down version of the relevant code:

# This is an Automator-built application
# Its name is "Foobar"
# This script works, but it would be more elegant (and future-proof) to refer to the application
# programmatically, rather than by hard-coding the name into the script, but how??

tell application "Foobar"
	activate
end tell

# Do some other stuff

Hi. Welcome to MacScripter.

If the workflow’s saved as an application, you should be able to use just:

activate

… or:

tell me to activate

… or:

tell current application to activate

Thanks, Neil!
The third suggestion worked. The first two did not work for me.
What primer or other resource would you recommend I study, so I can know these things for myself?

Yes. That makes sense. Sorry. ‘me’ is the script itself, while ‘current application’ is the application running it. The two can be the same when a script’s saved as an application, but apparently not when it’s part of an Automator workflow saved as such.

Apple’s own AppleScript Language Guide is probably still the best resource for telling you what’s actually in the language. It’s mention of the ‘current application’ constant is here.