apps starting when script starts and I don't want them to

I’ve got a script that is kiosk type menu and it works fine except one thing. It starts all the programs it controls in the background before it starts. I’d really like to supress this. Does anyone know how?

Depending on your needs, there are various tricks. This one is simple:

set app1 to "TextEdit"
set app2 to "iTunes"

run script "tell app \"" & app1 & "\" to set text of (make new document) to \"OK\""

run script "tell app \"" & app2 & "\" to playpause"

Obviously, for a mid-length or long script, you may need help debugging, etc. So, this is the most usual code:

set app1 to "TextEdit"
set app2 to "iTunes"

using terms from application "TextEdit"
	tell application app1
		set text of (make new document) to "OK"
	end tell
end using terms from

using terms from application "iTunes"
	tell application app2
		playpause
	end tell
end using terms from

And this is the third method I know:

set app1 to "TextEdit"
set app2 to "iTunes"

tell application app1
	set text of (make new document) to "OK"
end tell

tell application app2
	«event hookPlPs»
end tell

In this example, we’re lucky we can use some “standard” words, such as “text”, “make new” and “document”. Otherwise, we must know the raw-code equivalents, as with iTunes’ command “playpause”. For example:

set app1 to "Safari"

set js to "x=window.open();x.document.open();x.document.write('OK');x.document.close()"
tell application app1
	«event sfridojs» js given «class dcnm»:document 1
end tell

There are various tools which could help you here, but obviously, this is not a very smart way :stuck_out_tongue:

Hi,

You probably have something in your script that is making the apps launch.

gl,

Whenever I load a script to edit it, all the applications that have tell blocks in it, get opened. Maybe so that the dictionaries for them can be pre-loaded or something like that. It doesn’t happen when I run the script though, they just open once the tell block is reached.

Which one is the case for you?

I’m assuming your script is actually an AS Studio app, due to the forum you posted this in. Depending on how your script is structured, you could potentially separate the code for the various apps into separate script objects. This way, the apps will not actually launch until called from an event handler.