我正在尝试编写一个脚本:
我打算使用iCal来安排运行脚本,但实际脚本应该是什么样的?它可以在后台运行而不显示任何窗口吗?
答案 0 :(得分:0)
大多数本机应用程序都支持这样的UI脚本:
reopen application "Finder" -- open a default window if there are no open windows
tell application "System Events" to tell process "Finder"
repeat 3 times
click button 2 of window 1
delay 1
end repeat
end tell
如果您收到“禁用辅助设备访问”等错误,请从辅助功能首选项窗格中启用对辅助设备的访问。
如果您有Xcode,则可以使用辅助功能检查器检查UI元素。或者使用这样的东西:
reopen application "Finder"
tell application "System Events" to tell process "Finder" to tell window 1
{class, value} of UI elements of UI elements
description of UI elements
properties of some UI element
attributes of some UI element
value of attribute "AXFocused" of some UI element
actions of button 2
end tell
如果click
不起作用,请尝试perform action "AXPress"
,set selected to true
或set focused to true
。