You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何去除AppleScript命令行输出中的烦扰性"OK"字样?

解决AppleScript命令行读取字符串时输出带"OK"的问题

修正后的脚本

on run prompt
    set theResponse to display dialog prompt default answer ""
    return text returned of theResponse
end run

问题原因

你之前的脚本错误使用了text属性,display dialog返回的记录中,用户输入的文本对应的正确属性是text returned,而button returned属性对应点击的按钮(如"OK")。错误的属性调用导致输出包含了按钮标识,修正后脚本会仅返回用户输入的目标字符串。

命令行运行示例

用osascript执行脚本时,直接传入提示文本即可:

osascript your_script.scpt "请输入内容"

内容的提问来源于stack exchange,提问作者Att Righ

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 11:02:49