Categories
Computers

AppleScript trick


If you have multiple copies of the same application on your hard disk, it can be a bit unpredictable which one will launch if you say
tell application "MyApp" to activate
in AppleScript.
Here is a code snippet I figured out for making sure it is the one in the /Applications directory that gets launched.
set mypath to ""
tell application "Finder" to set mypath to path to the "apps" from system domain as string
set mypath to mypath & "MyApp.app"
tell application mypath to activate

3 replies on “AppleScript trick”

So what exactly is the advantage of having multiple copies of the same application on your hard drive?

Developers often build multiple versions of the same application. One version is usually “Debug”. This version runs more slowly, and is much larger than the other, “Release” version. The “Release” version is what you ship to customers. But, the “Debug” version can be debugged via a tool called “the debugger”. The debugger allows you to step through the source code for the program, and allows you to inspect variables, threads, the stack, etc…. Debug versions are crucial for tracking down strange behaviors in new programs.

Comments are closed.