Applescript launching program, but not switching to it

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
laurpapo
Posts: 38
Joined: Thu Jun 21, 2012 4:25 pm

Applescript launching program, but not switching to it

Post by laurpapo » Fri Apr 05, 2013 4:53 pm

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10323
Joined: Wed May 06, 2009 2:28 pm

Re: Applescript launching program, but not switching to it

Post by dunbarx » Fri Apr 05, 2013 6:58 pm

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

Post Reply