ui-automation 0.1.1

Control the User Interface, cross-platform.
Documentation
// Copyright (C) 2024 Tristan Gerritsen <tristan@thewoosh.org>
// All Rights Reserved.

use lazy_static::lazy_static;

use crate::backend::macos::core_foundation::{CFSerializable, CFString, CFStringRef};

lazy_static! {
    static ref CHILDREN: CFString = "AXChildren".into();
    static ref DESCRIPTION: CFString = "AXDescription".into();
    static ref POSITION: CFString = "AXPosition".into();
    static ref ROLE: CFString = "AXRole".into();
    static ref SIZE: CFString = "AXSize".into();
    static ref TITLE: CFString = "AXTitle".into();
    static ref URL: CFString = "AXURL".into();
    static ref WINDOWS: CFString = "AXWindows".into();
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AXUIAttribute {
    Children,
    Description,
    Position,
    Role,
    Size,
    Title,
    Url,
    Windows,
}

impl AXUIAttribute {
    #[must_use]
    pub fn marshal(&self) -> CFStringRef {
        match self {
            Self::Children => CHILDREN.to_ptr(),
            Self::Description => DESCRIPTION.to_ptr(),
            Self::Position => POSITION.to_ptr(),
            Self::Role => ROLE.to_ptr(),
            Self::Size => SIZE.to_ptr(),
            Self::Title => TITLE.to_ptr(),
            Self::Url => URL.to_ptr(),
            Self::Windows => WINDOWS.to_ptr(),
        }
    }
}