在另一个 AppleScript 中导入 AppleScript 方法? [英] Import AppleScript methods in another AppleScript?
问题描述
有没有办法在其他引用原始 AppleScript 的 AppleScript 中使用定义的 AppleScript 方法,这些方法类似于 import(例如在 PHP 中)?
Is there a way to use defined AppleScript methods in other AppleScripts which reference the original AppleScript with something similar to import (f.e. in PHP)?
我写了一个方法来设置 Skype 状态和心情文本:
I wrote a methode to set Skype status and mood-text:
on setSkypeStatus(status, mood_text)
tell application "System Events"
set skypeRunning to count (every process whose name is "Skype")
if skypeRunning > 0 then --only set status if skype is running
tell application "Skype"
set myStatus to "SET USERSTATUS " & status
set myMood to "SET PROFILE MOOD_TEXT " & mood_text
send command myStatus script name "AppleScript"
send command myMood script name "AppleScript"
return skypeRunning
end tell
else
return skypeRunning
end if
end tell
end setSkypeStatus
现在我正在搜索import skype_methods.scpt之类的东西.有没有这样的功能.我无法与 Google 相关联.
now I'm searching for something like import skype_methods.scpt. Is there such a functionality. I can't something related with Google.
推荐答案
将另一个脚本作为库导入的一种方法是定义一个属性,该属性通过将库加载为脚本对象来初始化.然后您可以使用 tell
命令来调用库函数.
One way to import another script as a library is to define a property which is initialized by loading the library as a script object. You can then use the tell
command to invoke the library functions.
property pSkypeLibrary : load script POSIX file "/Users/sakra/Desktop/skype_methods.scpt"
tell pSkypeLibrary
setSkypeStatus("status", "mood")
end tell
这篇关于在另一个 AppleScript 中导入 AppleScript 方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!