Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Iriverboys

macrumors newbie
Original poster
May 2, 2010
4
0
I'm trying to make a program that repeats a group of actions over and over again. I want the program to end either if the program has repeated a certain number of times or if a certain key is pressed (specifically the escape key). Is there an easy way to do this? If so, what? If not, what would the complicated way be?

What I want to be done:

repeat x times or until esc pressed

action

end repeat

What would the coding for this look like in AppleScript?
 
You are going to have to do two things for this:

1) Use an "on keyboard down" handler to fire whenever the escape key is pressed and set a variable to tell the other portion that it should stop.

2) Use a "on idle" handler to actually do the work. You are going to need to set a variable to count down the repetitions in this, and stop calling this back (ie: don't return anything, or drop out of the script).

Information on both of these can be found using google searches with "AppleScript" + the name of the handler.
 
What would these scripts look like?
Or, more specifically, what exactly would I have to do to do those things?
 
What would these scripts look like?
Or, more specifically, what exactly would I have to do to do those things?

1) Do some research on the two handlers I have told you about.

2) Play around with them and learn how they work.

3) If you get stuck once you have done a lot of this, then ask specific questions.

I am not going to spoon feed you.
 
Thank you very much larkost.

I was only asking because I have very, very little programming experience and had no clue where I would even begin to work with what you told me.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.