Page 1 of 1

Applescript launching program, but not switching to it

Posted: Fri Apr 05, 2013 4:53 pm
by laurpapo
Hi,

I have a program that is supposed to switch to the game pacman during it. I've got it to launch the pacman program, but it stays in revolution and doesn't switch windows to pacman (this is important because it's for an experiment). Here is my code:

Code: Select all

on pacmanproc
   put the text of field "Instructions5" of card "Materials" into field "Field" of card "Instructions"
   go to card "Instructions"
   wait until gPressed1 is true with messages
   put false into gPressed1
   go to cd "blank"
   do fld "activatePacMan" of cd "materials" as applescript
   wait pacmantime seconds with messages
   do fld "activateRev" of cd "materials" as applescript
end pacmanproc
And the field "activate pacman" says:

tell application "Pacman"
activate
end tell

Any helpful hints for me?

Thanks!

laurpapo

Re: Applescript launching program, but not switching to it

Posted: Fri Apr 05, 2013 6:58 pm
by dunbarx
Hi.

How does "gPressed1" become "true"?

In other words, is the script waiting forever for this to happen? Just a quick thought.

Also, and I am not sure this matters, is it possible that your default field name "field" may have others similarly named? LC will address the field with the lowest layer in such a case, and it may not be the one you intended. You should always give objects unique names, even if it is "field1", "field2" etc.

Craig Newman