是否可以为使用 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/