AppleScript - Execute Individually

An instant messenger which can connect to AIM, GTalk, Jabber, ICQ, and more.
Post Reply
error792
Harmless
Posts: 3
Joined: Sun May 13, 2007 8:22 am

AppleScript - Execute Individually

Post 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?
User avatar
evands
Cocoaforge Admin
Posts: 3152
Joined: Thu Dec 02, 2004 10:55 pm
Location: Decatur, GA
Contact:

Post 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.
The duck still burns.
--
My company: Saltatory Software. Check it out :)
error792
Harmless
Posts: 3
Joined: Sun May 13, 2007 8:22 am

Post 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.
User avatar
evands
Cocoaforge Admin
Posts: 3152
Joined: Thu Dec 02, 2004 10:55 pm
Location: Decatur, GA
Contact:

Post by evands »

Put a significant wait in nudge.scpt outside the adium tell statements -- is that osascript properly returning immediately in nudgewar.scpt?
The duck still burns.
--
My company: Saltatory Software. Check it out :)
Post Reply