#
hs.application
Manipulate running applications
#
Submodules
#
API Overview
Variables - Configurable values
menuGlyphs
Functions - API calls offered directly by the extension
applicationForPID applicationsForBundleID defaultAppForUTI enableSpotlightForNameSearches frontmostApplication infoForBundleID infoForBundlePath launchOrFocus launchOrFocusByBundleID localizationsForBundleID localizationsForBundlePath nameForBundleID pathForBundleID preferredLocalizationsForBundleID preferredLocalizationsForBundlePath runningApplications
Constructors - API calls which return an object, typically one that offers API methods
find get open
Methods - API calls which can only be made on an object returned by a constructor
activate allWindows bundleID findMenuItem findWindow focusedWindow getMenuItems getWindow hide isFrontmost isHidden isRunning kill kill9 kind mainWindow name path pid selectMenuItem setFrontmost title unhide visibleWindows
#
API Documentation
#
Variables
#
menuGlyphs
Signature | hs.application.menuGlyphs |
Type | Variable |
Description | A table containing UTF8 representations of the defined key glyphs used in Menus for keyboard shortcuts which are presented pictorially rather than as text (arrow keys, return key, etc.) |
Notes |
|
Source | extensions/application/application.lua line 239 |
#
Functions
#
applicationForPID
Signature | hs.application.applicationForPID(pid) -> hs.application object or nil |
Type | Function |
Description | Returns the running app for the given pid, if it exists. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 54 |
#
applicationsForBundleID
Signature | hs.application.applicationsForBundleID(bundleID) -> list of hs.application objects |
Type | Function |
Description | Returns any running apps that have the given bundleID. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 71 |
#
defaultAppForUTI
Signature | hs.application.defaultAppForUTI(uti) -> string or nil |
Type | Function |
Description | Returns the bundle ID of the default application for a given UTI |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 215 |
#
enableSpotlightForNameSearches
Signature | hs.application.enableSpotlightForNameSearches([state]) -> boolean |
Type | Function |
Description | Get or set whether Spotlight should be used to find alternate names for applications. |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | extensions/application/application.lua line 429 |
#
frontmostApplication
Signature | hs.application.frontmostApplication() -> hs.application object |
Type | Function |
Description | Returns the application object for the frontmost (active) application. This is the application which currently receives input events. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 21 |
#
infoForBundleID
Signature | hs.application.infoForBundleID(bundleID) -> table or nil |
Type | Function |
Description | Gets the metadata of an application from its bundle identifier |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 119 |
#
infoForBundlePath
Signature | hs.application.infoForBundlePath(bundlePath) -> table or nil |
Type | Function |
Description | Gets the metadata of an application from its path on disk |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 199 |
#
launchOrFocus
Signature | hs.application.launchOrFocus(name) -> boolean |
Type | Function |
Description | Launches the app with the given name, or activates it if it's already running |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | extensions/application/libapplication.m line 1092 |
#
launchOrFocusByBundleID
Signature | hs.application.launchOrFocusByBundleID(bundleID) -> boolean |
Type | Function |
Description | Launches the app with the given bundle ID, or activates it if it's already running |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | extensions/application/libapplication.m line 1111 |
#
localizationsForBundleID
Signature | hs.application.localizationsForBundleID(bundleID) -> table or nil |
Type | Function |
Description | Gets a list of all the localizations contained in the bundle. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 167 |
#
localizationsForBundlePath
Signature | hs.application.localizationsForBundlePath(bundlePath) -> table or nil |
Type | Function |
Description | Gets a list of all the localizations contained in the bundle. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 183 |
#
nameForBundleID
Signature | hs.application.nameForBundleID(bundleID) -> string or nil |
Type | Function |
Description | Gets the name of an application from its bundle identifier |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 87 |
#
pathForBundleID
Signature | hs.application.pathForBundleID(bundleID) -> string or nil |
Type | Function |
Description | Gets the filesystem path of an application from its bundle identifier |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 103 |
#
preferredLocalizationsForBundleID
Signature | hs.application.preferredLocalizationsForBundleID(bundleID) -> table or nil |
Type | Function |
Description | Gets an ordered list of preferred localizations contained in a bundle |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 135 |
#
preferredLocalizationsForBundlePath
Signature | hs.application.preferredLocalizationsForBundlePath(bundlePath) -> table or nil |
Type | Function |
Description | Gets an ordered list of preferred localizations contained in a bundle |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 151 |
#
runningApplications
Signature | hs.application.runningApplications() -> list of hs.application objects |
Type | Function |
Description | Returns all running apps. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 37 |
#
Constructors
#
find
Signature | hs.application.find(hint, exact, stringLiteral) -> hs.application object(s) |
Type | Constructor |
Description | Finds running applications |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | extensions/application/application.lua line 106 |
#
get
Signature | hs.application.get(hint) -> hs.application object |
Type | Constructor |
Description | Gets a running application |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | extensions/application/application.lua line 87 |
#
open
Signature | hs.application.open(app[, wait, [waitForFirstWindow]]) -> hs.application object |
Type | Constructor |
Description | Launches an application, or activates it if it's already running |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | extensions/application/application.lua line 202 |
#
Methods
#
activate
Signature | hs.application:activate([allWindows]) -> bool |
Type | Method |
Description | 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. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/application.lua line 62 |
#
allWindows
Signature | hs.application:allWindows() -> list of hs.window objects |
Type | Method |
Description | Returns all open windows owned by the given app. |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | extensions/application/libapplication.m line 246 |
#
bundleID
Signature | hs.application:bundleID() -> string |
Type | Method |
Description | Returns the bundle identifier of the app. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 349 |
#
findMenuItem
Signature | hs.application:findMenuItem(menuItem[, isRegex]) -> table or nil |
Type | Method |
Description | Searches the application for a menu item |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | extensions/application/libapplication.m line 764 |
#
findWindow
Signature | hs.application:findWindow(titlePattern) -> hs.window object(s) |
Type | Method |
Description | Finds windows from this application |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/application.lua line 175 |
#
focusedWindow
Signature | hs.application:focusedWindow() -> hs.window object or nil |
Type | Method |
Description | Returns the currently focused window of the application, or nil |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 289 |
#
getMenuItems
Signature | hs.application:getMenuItems([fn]) -> table or nil | hs.application object |
Type | Method |
Description | Gets the menu structure of the application |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | extensions/application/libapplication.m line 1025 |
#
getWindow
Signature | hs.application:getWindow(title) -> hs.window object |
Type | Method |
Description | Gets a specific window from this application |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/application.lua line 189 |
#
hide
Signature | hs.application:hide() -> boolean |
Type | Method |
Description | Hides the app (and all its windows). |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 421 |
#
isFrontmost
Signature | hs.application:isFrontmost() -> boolean |
Type | Method |
Description | Returns whether the app is the frontmost (i.e. is the currently active application) |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 490 |
#
isHidden
Signature | hs.application:isHidden() -> boolean |
Type | Method |
Description | Returns whether the app is currently hidden. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 473 |
#
isRunning
Signature | hs.application:isRunning() -> boolean |
Type | Method |
Description | Checks if the application is still running |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | extensions/application/libapplication.m line 383 |
#
kill
Signature | hs.application:kill() |
Type | Method |
Description | Tries to terminate the app gracefully. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 439 |
#
kill9
Signature | hs.application:kill9() |
Type | Method |
Description | Tries to terminate the app forcefully. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 456 |
#
kind
Signature | hs.application:kind() -> number |
Type | Method |
Description | Identify the application's GUI state |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 547 |
#
mainWindow
Signature | hs.application:mainWindow() -> hs.window object or nil |
Type | Method |
Description | Returns the main window of the given app, or nil. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 272 |
#
name
Signature | hs.application:name() |
Type | Method |
Description | Alias for hs.application:title() |
Parameters | |
Returns | |
Notes | None |
Source | extensions/application/application.lua line 82 |
#
path
Signature | hs.application:path() -> string |
Type | Method |
Description | Returns the filesystem path of the app. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 366 |
#
pid
Signature | hs.application:pid() -> number |
Type | Method |
Description | Returns the app's process identifier. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 530 |
#
selectMenuItem
Signature | hs.application:selectMenuItem(menuitem[, isRegex]) -> true or nil |
Type | Method |
Description | Selects a menu item (i.e. simulates clicking on the menu item) |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | extensions/application/libapplication.m line 855 |
#
setFrontmost
Signature | hs.application:setFrontmost([allWindows]) -> boolean |
Type | Method |
Description | Sets the app to the frontmost (i.e. currently active) application |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 507 |
#
title
Signature | hs.application:title() -> string |
Type | Method |
Description | Returns the localized name of the app (in UTF8). |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 332 |
#
unhide
Signature | hs.application:unhide() -> boolean |
Type | Method |
Description | Unhides the app (and all its windows) if it's hidden. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/libapplication.m line 403 |
#
visibleWindows
Signature | hs.application:visibleWindows() -> win[] |
Type | Method |
Description | Returns only the app's windows that are visible. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/application/application.lua line 46 |