Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import AppleScript methods in another AppleScript?

Tags:

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)?

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 

now I'm searching for something like import skype_methods.scpt. Is there such a functionality. I can't something related with Google.

like image 914
Jens Kohl Avatar asked Apr 09 '10 09:04

Jens Kohl


People also ask

Does Apple still use AppleScript?

AppleScript is a scripting language created by Apple Inc. that facilitates automated control over scriptable Mac applications. First introduced in System 7, it is currently included in all versions of macOS as part of a package of system automation tools.

Why is AppleScript so slow?

Don't overdo AppleScript formatting.The slowdown is caused when your script editor is forced to cope with growing numbers of style runs as it displays your script following a compile. The answer is to keep the number of formats you use to a minimum.

Is AppleScript a scripting language?

What Is AppleScript? AppleScript is a scripting language created by Apple. It allows users to directly control scriptable Macintosh applications, as well as parts of macOS itself.


1 Answers

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 
like image 95
sakra Avatar answered Oct 14 '22 14:10

sakra