Bad*_*ate 1 macos shell applescript automator
是否可以在自动化工作流程(特别是服务流程)中存储持久值?
看来常规自动机变量不是持久的;例如,尝试使用具有属性(通常持续存在)的 applescript 块实际上也不会在 Applescript 中保留该属性(在测试中有效,但当您运行服务时,该值不会持续)。
有任何想法吗?
您可以使用脚本对象将数据存储在一个偏僻的地方。

on run
-- Path of script which holds data
set thePath to (path to desktop as text) & "myData.scpt"
--set thePath to (path to preferences as text) & "myData.scpt" -- better
script theData
property xxx : missing value
end script
try
set theData to load script file thePath
on error
-- On first run, set the initial value of the variable
set theData's xxx to 5
end try
-- change the value of the variable
set theData's xxx to (theData's xxx) + 1
-- save your changes
store script theData in file thePath replacing yes
return theData's xxx
end run
Run Code Online (Sandbox Code Playgroud)