gpt4 book ai didi

applescript - AppleScript 应用程序的全局首选项

转载 作者:行者123 更新时间:2023-12-04 23:57:34 26 4
gpt4 key购买 nike

是否可以为使用 AppleScript 创建的应用程序保存某种设置?

设置应在脚本开始时加载,并在脚本结束时保存。

例子:

if loadSetting("timesRun") then
set timesRun to loadSetting("timesRun")
else
set timesRun to 0
end if
set timesRun to timesRun + 1
display dialog timesRun
saveSetting("timesRun", timesRun)

第一次运行脚本时对话框显示 1,第二次运行时显示 2...

而函数 loadSetting 和 saveSetting 将是我需要的函数。

最佳答案

脚本 properties是持久性的,但保存的值会在您重新保存脚本时被脚本中指定的值覆盖。运行:

property |count| : 0
display alert "Count is " & |count|
set |count| to |count| + 1

几次,重新保存,然后再运行几次。

如果你想使用用户默认系统,你可以使用 do shell script "defaults ..." 命令或(如果使用 Applescript Studio)用户的默认条目“propertyName”默认值。在 Applescript Studio 中,您 bind values to user defaults .

关于applescript - AppleScript 应用程序的全局首选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5902202/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com