要解决这个问题,您可以使用AppleScript的UI脚本功能来模拟鼠标点击操作。以下是一个示例代码,演示如何使用UI脚本来点击输入标签并添加文件:
tell application "System Events"
tell process "YourAppName"
-- 替换 "YourAppName" 为目标应用的名称
-- 确定输入标签的位置
set inputLabel to UI element 1 of group 1 of window 1
-- 模拟鼠标点击操作
click inputLabel
-- 添加文件的操作(根据实际情况修改)
keystroke "G" using {command down, shift down} -- 打开“前往”菜单
delay 0.5 -- 等待菜单打开
keystroke "YourFilePath" -- 输入文件路径
delay 0.5
keystroke return -- 确认路径
delay 0.5
end tell
end tell
请注意,您需要将代码中的 "YourAppName" 替换为目标应用的名称,并根据实际情况修改添加文件的操作。
另外,请确保您已在“系统偏好设置”>“安全性与隐私”>“隐私”>“辅助功能”中允许AppleScript控制您的计算机,以便使用UI脚本功能。
希望这可以帮助到您!