#[non_exhaustive]pub struct AppInfo {
pub name: String,
pub bundle_id: Option<String>,
pub pid: Option<u32>,
pub path: Option<PathBuf>,
pub is_running: bool,
pub is_active: bool,
pub window_title: Option<String>,
pub needs_restart: bool,
}Expand description
An application that is running or installed.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: StringHuman-readable name, e.g. TextEdit.
bundle_id: Option<String>Platform identifier: a bundle ID on macOS, an AUMID or executable name on Windows, a desktop-file ID on Linux.
pid: Option<u32>Process ID, when running.
path: Option<PathBuf>Path to the app bundle or executable.
is_running: boolWhether the app currently has a process.
is_active: boolWhether the app is the frontmost (focused) app.
window_title: Option<String>Title of the app’s main window, when the platform reports one. Queries also match it.
needs_restart: boolThe app is running but does not expose its UI to accessibility, so it cannot be inspected or controlled until it is quit and started again.
Only set on Linux, for browser-engine apps started before desktop accessibility was turned on.
Implementations§
Source§impl AppInfo
impl AppInfo
Sourcepub fn new(name: impl Into<String>) -> Self
pub fn new(name: impl Into<String>) -> Self
Creates a record for an app with only a name; fill the rest with the builder methods.
Sourcepub fn with_bundle_id(self, bundle_id: impl Into<String>) -> Self
pub fn with_bundle_id(self, bundle_id: impl Into<String>) -> Self
Sets the platform identifier.
Sourcepub const fn with_active(self, active: bool) -> Self
pub const fn with_active(self, active: bool) -> Self
Marks the app as frontmost.
Sourcepub const fn with_needs_restart(self, needs_restart: bool) -> Self
pub const fn with_needs_restart(self, needs_restart: bool) -> Self
Marks the app as running without an accessibility tree (see AppInfo::needs_restart).
Sourcepub fn with_window_title(self, title: impl Into<String>) -> Self
pub fn with_window_title(self, title: impl Into<String>) -> Self
Sets the main window title.
Sourcepub fn reference(&self) -> &str
pub fn reference(&self) -> &str
The identifier shown to callers: bundle ID when known, otherwise the name.
Examples found in repository?
6fn main() -> computer_use::Result<()> {
7 let computer = computer_use::Computer::new()?;
8 for app in computer.list_apps()? {
9 let status = match (app.is_running, app.is_active, app.needs_restart) {
10 (true, _, true) => "restart",
11 (true, true, _) => "active",
12 (true, false, _) => "running",
13 _ => "installed",
14 };
15 let pid = app.pid.map(|p| format!(" pid {p}")).unwrap_or_default();
16 println!("{:<9} {} [{}]{pid}", status, app.name, app.reference());
17 }
18 Ok(())
19}Sourcepub fn match_score(&self, query: &str) -> Option<u8>
pub fn match_score(&self, query: &str) -> Option<u8>
How well this app matches a user query; None means no match.
Queries may be a name, bundle ID, path, or pid:<n>. Lower scores are better.