跳到正文
所有工具

ui_click

屏幕、窗口与界面 · macOS · Windows

效果: 执行. 状态: 受限可用.

“受限可用”表示工具可能取决于版本、平台、权限、账户或配置,并不表示它在所有安装中都已启用。

macOS

用途

点击某个元素(通过 element_ref,点击其中心)或某个屏幕坐标(通过 coords)。button left|right,count 2 = 双击。返回 {clicked, at:{x,y}} —— `clicked` 表示点击事件已被投递到这些坐标,并不表示应用已作出响应:CGEvent 不带送达确认,因此忙碌、处于模态或忽略输入的应用报告的成功与正常情况完全相同。请用 ui_wait_for_element 或 ui_read_tree 确认效果,而不要相信 `clicked`。只有当应用确实发布 AXEnabled=false 时才会返回 element_disabled;完全不发布 AXEnabled 的控件被视为未知并照常点击。不发布位置的元素(网页内的某些控件)会被要求滚动到可见区域;若仍没有位置,则通过其辅助功能的按下操作执行一次左键点击,返回 {clicked, via:"press_action"} 且不含 `at`;若这也被拒绝,则错误为 no_bounds——请使用截图中的坐标。需要辅助功能权限。

必填输入

此平台的架构未声明必填输入,但仍可能存在可选选择器或运行时要求。

权限与确认

架构未声明明确的确认参数。这并不代表可以未经许可操作;请检查效果并取得授权。

英文规范技术架构 — macOS
{
  "properties": {
    "button": {
      "description": "Default left.",
      "enum": [
        "left",
        "right"
      ],
      "type": "string"
    },
    "by": {
      "description": "Default element if element_ref given, else coords.",
      "enum": [
        "element",
        "coords"
      ],
      "type": "string"
    },
    "coords": {
      "description": "{x,y} in global screen points.",
      "type": "object"
    },
    "count": {
      "description": "1 (default) or 2 for double-click.",
      "type": "integer"
    },
    "element_ref": {
      "description": "Element handle returned by ui_find_element or ui_read_tree; the click lands at that element's center. Needed when by=element, which is the default whenever element_ref is present.",
      "type": "string"
    }
  },
  "required": [],
  "type": "object"
}

文档示例

ui_click 的文档示例。请勿执行此示例。所示参数属于虚构数据集;在实际调用前,请解析真实标识符并获得授权。

{
  "coords": {
    "x": 100,
    "y": 100
  }
}

Windows

用途

点击元素(通过 element_ref,点击其中心)或屏幕坐标(通过 coords)。button 可为 left|right,count 2 表示双击。返回 {clicked, at:{x,y}};`clicked` 只表示点击已在这些坐标处发出,不表示应用已执行操作:SendInput 不提供投递确认,所以繁忙或显示模态窗口的应用也会报告相同的成功。应使用 ui_wait_for_element 或 ui_read_tree 确认效果,不要信任 `clicked`。

必填输入

此平台的架构未声明必填输入,但仍可能存在可选选择器或运行时要求。

权限与确认

架构未声明明确的确认参数。这并不代表可以未经许可操作;请检查效果并取得授权。

英文规范技术架构 — Windows
{
  "properties": {
    "button": {
      "description": "Default left.",
      "enum": [
        "left",
        "right"
      ],
      "type": "string"
    },
    "coords": {
      "description": "{x,y} in global screen pixels.",
      "type": "object"
    },
    "count": {
      "description": "1 (default) or 2 for double-click.",
      "type": "integer"
    },
    "element_ref": {
      "description": "Element handle returned by ui_find_element or ui_read_tree; the click lands at that element's center. Pass this or coords — a non-empty element_ref wins, and coords is only read when it is absent.",
      "type": "string"
    }
  },
  "required": [],
  "type": "object"
}

文档示例

ui_click 的文档示例。请勿执行此示例。所示参数属于虚构数据集;在实际调用前,请解析真实标识符并获得授权。

{
  "coords": {
    "x": 100,
    "y": 100
  }
}