Copy link to clipboard
Copied
Now i approached to squeezze out a sound from Mac by using 3rd part app:
tell application "Play Sound"
play "Mac:Users:me:Sounds:copied.wav"
end tell
Can i attach this scpt to my js-script in any way?
Thanks in advance.
Copy link to clipboard
Copied
The key is to put your appleScript into a string, and call the app.doScript() function.
Here's an example, by Kasyan Servetsky:
// Written by Kasyan Servetsky
var myDisk = GetStartUpDisk();
alert("The name of my start up disk is \"" + myDisk + "\"");
function GetStartUpDisk() {
if (File.fs == "Macintosh") {
var myScript = 'tell application \"Finder\"\r'
myScript += 'set myStartUpDisk to get name of startup disk\r';
myScript += 'end tell\r';
myScript += 'tell application \"Adobe InDesign CS' + ((parseInt(app.version.substr(0, 1)) - 2) + "") + '\"\r';
myScript += 'tell script args\r';
myScript += 'set value name \"myScriptArgument\" value myStartUpDisk\r';
myScript += 'end tell\r';
myScript += 'end tell\r';
app.doScript(myScript, ScriptLanguage.applescriptLanguage);
var myStartUpDisk = app.scriptArgs.getValue("myScriptArgument");
}
else if (File.fs == "Windows") {
var myStartUpDisk = String(Folder.system).charAt(1);
}
return myStartUpDisk;
}
Copy link to clipboard
Copied
i did this way:
function mSound() {
var myAppleScript = ("/Users/me/my misc/myscripting/mSound.applescript");
app.doScript(myAppleScript, ScriptLanguage.applescriptLanguage);
}
It works. Great!
Copy link to clipboard
Copied
Hi ,
MacOsx BuiltIn-Player is 'afPlay'. So there is no need for thirdPartApp
do shell script "afplay " & quoted form of POSIX path of ("Here:a:macpath!")
Nice Day
Copy link to clipboard
Copied
OK. But so far my Mac didn't found his afPlayer (( OK. So i shall use third-part app.
Copy link to clipboard
Copied
@-hans-:
Is your example a working applescript line or a javascript line? "do shell script"
Copy link to clipboard
Copied
Hi @all,
afPlay should be located at 'usr/bin/'
But there's no need to know this because this applescript line runs it:
do shell script "afplay " & quoted form of POSIX path of ("Here:a:macpath:to:a:soundfile!!!")
Here the link to its extensiv 😉 manPage: http://www.manpagez.com/man/1/afplay/
Copy link to clipboard
Copied
Copy link to clipboard
Copied
The shell can only handle posix path (unix path)
do shell script "afplay " & quoted form of POSIX path of ("Here:a:macpath:to:a:soundfile!!!")
Copy link to clipboard
Copied
Yes, if written correctly - afplay does work!
Thanks ))