Page 1 of 1
AppleScript - Execute Individually
Posted: Sun May 13, 2007 9:44 am
by error792
I'm trying to make a macro for nudge wars. The syntax is
/nudgewar{times}. The code is:
Code: Select all
on substitute(arg)
tell application "Adium"
repeat with i from 1 to arg
send the active chat of the first interface controller message "/nudge"
end repeat
end tell
end substitute
When the code executes, I'd like for Adium to send the nudges one after another; however, it currently sends them all at once. I've tried adding a delay command in the loop with no effect (other than delaying the all-in-one delivery of nudges). Any ideas on how I can fix this?
Posted: Sun May 13, 2007 10:34 am
by evands
Since Adium executes the script all at once, you have to use some sleight of hand. You'll need two parts, I belive. Have the applescript run a second thing -- another applescript or shell script which itself uses osascript to execute the applescript -- in a way that won't wait for called external program to finish.
Posted: Sun May 13, 2007 10:06 pm
by error792
I tried modifying the code to this:
File: nudgewar.scpt
Code: Select all
on substitute(arg)
do shell script ("osascript -l AppleScript $HOME/Library/Application\\ Support/Adium\\ 2.0/Scripts/Nudge\\ War.AdiumScripts/Contents/Resources/nudge.scpt " & arg & " &")
end substitute
File:nudge.scpt
Code: Select all
on run argv
repeat with i from 1 to first item of argv
tell application "Adium"
send the active chat of the first interface controller message "/nudge"
end tell
end repeat
end run
But it still sends everything all at once.
Posted: Sun May 13, 2007 11:57 pm
by evands
Put a significant wait in nudge.scpt outside the adium tell statements -- is that osascript properly returning immediately in nudgewar.scpt?