mjolnir.application

Manipulate running applications.

applicationforpid

mjolnir.application.applicationforpid(pid) -> app or nil

Returns the running app for the given pid, if it exists.

applicationsforbundleid

mjolnir.application.applicationsforbundleid(bundleid) -> app[]

Returns any running apps that have the given bundleid.

launchorfocus

mjolnir.application.launchorfocus(name) -> bool

Launches the app with the given name, or activates it if it's already running.
Returns true if it launched or was already launched; otherwise false (presumably only if the app doesn't exist).

runningapplications

mjolnir.application.runningapplications() -> app[]

Returns all running apps.

activate

mjolnir.application:activate(allwindows = false) -> bool

Tries to activate the app (make its key window focused) and returns whether it succeeded; if allwindows is true, all windows of the application are brought forward as well.

allwindows

mjolnir.application:allwindows() -> window[]

Returns all open windows owned by the given app.

bundleid

mjolnir.application:bundleid() -> string

Returns the bundle identifier of the app.

hide

mjolnir.application:hide() -> success

Hides the app (and all its windows).

ishidden

mjolnir.application:ishidden() -> bool

Returns whether the app is currently hidden.

kill

mjolnir.application:kill()

Tries to terminate the app.

kill9

mjolnir.application:kill9()

Assuredly terminates the app.

kind

mjolnir.application:kind() -> number

Returns 1 if the app is in the dock, 0 if not, and -1 if it can't even have GUI elements if it wanted to.

mainwindow

mjolnir.application:mainwindow() -> window

Returns the main window of the given app, or nil.

pid

mjolnir.application:pid() -> number

Returns the app's process identifier.

title

mjolnir.application:title() -> string

Returns the localized name of the app (in UTF8).

unhide

mjolnir.application:unhide() -> success

Unhides the app (and all its windows) if it's hidden.

visiblewindows

mjolnir.application:visiblewindows() -> win[]

Returns only the app's windows that are visible.