由于您正在Automator中使用Automator和AppleScript,并且您还没有发布任何实际代码,因此很难给出您所要查找的内容的确切答案。
可能有一个更简单的解决方案,但我想到的解决方案是创建一个脚本,将变量保存到新的脚本文件中(该脚本将在桌面上自动创建,名称为Stored\u variable.scpt。第二个脚本加载存储在Stored\u variable.scpt文件中的变量的值)。
只需将第一个脚本中的代码直接粘贴到包含要复制的变量的代码中。确保将代码粘贴在设置要复制的变量值的代码之后。
-- Comment Out This Next Line Before
-- Placing This Code Into Your Script
-- Which Contains The Variable You Want Copied
set originalVariable to (path to desktop) -- Testing Purposes Only
-- Replace "originalVariable" with the
-- Name Of Your Actual Variable You Want To Pass
-- To The Next Script
set saveThisVariable to originalVariable
storeTheVariable()
-- The Following Code Belongs At The Very Bottom Of Your Script
on storeTheVariable()
set storedVariabeFileLocation to (path to desktop as text) & "Stored_Variable.scpt"
----------------------
script theVariable
set saveThisVariable to saveThisVariable
end script
----------------------
store script theVariable in ¬
file storedVariabeFileLocation with replacing
end storeTheVariable
将这是第二个代码放在AppleScript的代码中,您将在其中尝试从第一个AppleScript代码中检索存储的变量
-- Gets The Variable Which Was Previously Stored
-- From The Other Applescript And Stores It In A
-- New Variable... getVariableNow
set getVariableNow to run loadTheVariable
-- -----------------------------------
-- Place Whatever Commands Here, That You Will Be Using
-- The New Variable... getVariableNow with
-- -----------------------------------
-- The Following Code Belongs At The Very Bottom Of Your Script
script loadTheVariable
property storedVariabeFileLocation : (path to desktop as text) & "Stored_Variable.scpt"
property theRetrievedVariable : missing value
on getStoredVariable()
set theScript to load script file storedVariabeFileLocation
set theRetrievedVariable to saveThisVariable of (theVariable of theScript)
end getStoredVariable
set theRetrievedVariable to loadTheVariable's getStoredVariable()
end script