Does anyone know when you run two process in unix, do they run almost simultaneously. For example, the following script runs two processes:
set script1 to quoted form of "delay 1
return 1"
set script2 to quoted form of "say \"Hello\" without waiting until completion
return 2"
do shell script "(osascript -e " & script1 & " & osascript -e " & script2 & ")"
Edited: should have said in almost parallel.
Edited: Narrowed it down to about 0.085 secs for the say command. Don’t know how accurate this is:
set script1 to quoted form of "delay .084
return 1"
set script2 to quoted form of "say \"Hello\" without waiting until completion
return 2"
do shell script "(osascript -e " & script1 & " & osascript -e " & script2 & ")"
Only one say command is being called at a time – it’s just that the command you’re calling is asynchronous. Whether you can do that depends a lot on what you are actually doing. I’m not sure what you mean about two processes in unix – we’d be in trouble if it couldn’t happen…
So today I can post what I wanted to post the other day. This requires 10.9. Save the following script as a .scptd bundle in ~/Library/Script Libraries/ (you will probably have to make the folder). When you have saved it from ASE, click on the Bundle Contents button in the toolbar, and check the AppleScript/Objective-C Library button. Save.
use AppleScript version "2.3"
use scripting additions
use framework "Foundation"
use framework "AppKit" -- for NSSpeechSynthesizer
property theSender : missing value
on startSaying:theString sender:sender
set my theSender to sender -- store in property for later use
set theSynth to current application's NSSpeechSynthesizer's new()
theSynth's setDelegate:me
theSynth's startSpeakingString:theString
end startSaying:sender:
-- delegate methods
on speechSynthesizer:anNSSpeechSynthesizer willSpeakWord:anNSRange ofString:aString
log (aString's substringWithRange:anNSRange) as text
end speechSynthesizer:willSpeakWord:ofString:
on speechSynthesizer:anNSSpeechSynthesizer didFinishSpeaking:theFlag
theSender's stringSpoken:(theFlag as integer)
end speechSynthesizer:didFinishSpeaking:
Now open a new script window, and enter this, changing the script name to the name of the file you just saved (without extension):
use theLib : script "<script filename>"
use scripting additions
theLib's startSaying:"Hello world, welcome to AppleScriptObjC" sender:me
on stringSpoken:theFlag
if theFlag = 1 then
log "The string was spoken"
else
log "Trouble at mill"
end if
end stringSpoken:
Great! I was planning to get Maverick once I figure out a safe way to make payments on the internet. I used to use credit cards, but don’t want to do that now.
Sometimes things that are too good to be true, happens to be true!
Not that that happens too often. I have read the review at Ars and free is of course very good, but this version has a lot more qualities too it than just being free. As I see it, the whole thing is a big leap in the right direction.
The only thing missing, is the ability to add applets to all window toolbars in all programs!
I have to wait until tonight to update to Maverick. The wifi might be too slow during the day and evening. Still need to plan how to backup all the files anyway. Then, I can try Shane’s script. Can’t wait to try Maverick. I wonder if Maverick fixes the slowness in Civ 5.