簡體   English   中英

使用Apple Script單擊按鈕

[英]Clicking button using Apple Script

我想從Apple腳本向UI應用程序添加一些細節。 但是我無法在腳本中單擊UI中的“新建”按鈕。

tell application "System Events" to tell process "Microsoft Remote Desktop"
    --click button 1 of group 1 of toolbar 1 of window 1
    click button "New" of group 1 of toolbar 1 of window 1
end tell

MSTSC

輔助功能檢查器

在此處輸入圖片說明

你不能用“新”的按鈕的 name ,因為該數值 name屬性 button 1 of group 1 of toolbar 1 of window 1 of application process "Microsoft Remote Desktop"missing value

然而,對於該 description 屬性New ,所以下面的示例 代碼 的AppleScript工作對我來說:

activate application "Microsoft Remote Desktop"
delay 1
tell application "System Events" to tell application process "Microsoft Remote Desktop"
    click (every button of group 1 of toolbar 1 of window 1 whose description is "New")
end tell
  • 請注意,可能需要針對您的系統調整delay 命令 ,或者可能需要也可能不需要其他delay 命令 適當調整和的 ,或添加/刪除delay 命令

如果僅在打開主窗口的情況下已經運行Microsoft遠程桌面,則可以使用以下示例代碼行獲取button 1 of group 1 of toolbar 1 of window 1button 1 of group 1 of toolbar 1 of window 1屬性

tell application "System Events" to get properties of button 1 of group 1 of toolbar 1 of window 1 of application process "Microsoft Remote Desktop"

注意: 示例 AppleScript 代碼就是這樣,它沒有任何錯誤處理 ,僅用於說明完成任務的多種方式之一。 用戶有責任根據需要/需要添加/使用適當的錯誤處理

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM