Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'telling' a specific application by a specific full path using Applescript

I am looking to tell application "xyz", but by specifying a full path to the application. This is because there may be various versions of the app on the system in different places, but with the same name. If this possible?

like image 814
Mathieu Tozer Avatar asked Jun 01 '11 12:06

Mathieu Tozer


People also ask

What is alias in AppleScript?

Description. An alias type is a representation of a disk, folder, or volume. An alias is a form of referring to an object such as a file (as in the syntax example), which is very similar to the “alias files” that you can create in the Finder.

How do I run AppleScript on Mac?

In the Script Editor app on your Mac, click the Run button in the toolbar, or press Command-R, to execute the commands in your script.

What script does Apple use?

What Is AppleScript? AppleScript is a scripting language created by Apple. It allows users to directly control scriptable Macintosh applications, as well as parts of macOS itself.


2 Answers

Have you tried it? It works with either a posix style path or mac style path, so what's the issue? It couldn't be easier.

set posixCalculatorPath to "/Applications/Calculator.app"
set macCalculatorPath to (path to applications folder as text) & "Calculator.app"

tell application posixCalculatorPath to activate

delay 2

tell application "Calculator" to quit

delay 2

tell application macCalculatorPath to activate

One thing that you might not know how to do is to find the path to the application you want to target. I have created a tool found here which, if you feed it the path to a file then it will return the paths to all of the applications that could open that file. So that result would tell you if there is multiple applications with the same name and then you could choose which one to use.

like image 128
regulus6633 Avatar answered Sep 17 '22 20:09

regulus6633


launch application ":Applications:TextEdit.app"

tell application ":Applications:TextEdit.app" to launch
like image 45
1.61803 Avatar answered Sep 21 '22 20:09

1.61803