Signature |
hs.application.find(hint, exact, stringLiteral) -> hs.application object(s) |
Type |
Constructor |
Description |
Finds running applications
|
Parameters |
- hint - search criterion for the desired application(s); it can be: - a pid number as per
hs.application:pid() - a bundle ID string as per hs.application:bundleID() - a string pattern that matches (via string.find ) the application name as per hs.application:name() (for convenience, the matching will be done on lowercased strings) - a string pattern that matches (via string.find ) the application's window title per hs.window:title() (for convenience, the matching will be done on lowercased strings)
- exact - a boolean, true to check application names for exact matches, false to use Lua's string:find() method. Defaults to false
- stringLiteral - a boolean, true to interpret the hint string literally, false to interpret it as a Lua Pattern. Defaults to false.
|
Returns |
- one or more hs.application objects for running applications that match the supplied search criterion, or
nil if none found
|
Notes |
- If multiple results are found, this function will return multiple values. See https://www.lua.org/pil/5.1.html for more information on how to work with this
- for convenience you can call this as
hs.application(hint)
- use this function when you don't know the exact name of an application you're interested in, i.e.
from the console:
hs.application'term' --> hs.application: iTerm2 (0x61000025fb88) hs.application: Terminal (0x618000447588) .
But be careful when using it in your init.lua : terminal=hs.application'term' will assign either "Terminal" or "iTerm2" arbitrarily (or even,
if neither are running, any other app with a window that happens to have "term" in its title); to make sure you get the right app in your scripts,
use hs.application.get with the exact name: terminal=hs.application.get'Terminal' --> "Terminal" app, or nil if it's not running
Usage:
-- by pid
hs.application(42):name() --> Finder
-- by bundle id
hs.application'com.apple.Safari':name() --> Safari
-- by name
hs.application'chrome':name() --> Google Chrome
-- by window title
hs.application'bash':name() --> Terminal
|
Source |
extensions/application/application.lua line 106 |