Search code examples
javascript-automation

Documentation on Application.launch() in JXA?


Where can I find documentation on Application.launch() in JXA?

Application('Safari').launch();

It seems Application.launch(), unlike Application.activate(), only starts the application process without actually open or activate an application window.

I searched the Internet and find no documentation on this function.


Solution

  • The launch command:

    Launches an application, if it is not already running, but does not send it a run command.

    If an application is already running, sending it a launch command has no effect. That allows you to open an application without performing its usual startup procedures, such as opening a new window or, in the case of a script application, running its script. For example, you can use the launch command when you don’t want an application to open and close visibly.

    via https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW51

    Note that while the above documentation is for AppleScript, it mostly applies to JXA, too.