You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

AppleScript 101 - How do I make random values?

How do I create random values in AppleScript? For instance, if I wanted to create a delay of 40-50 seconds which random selects a number in between there?

Also, how would I do for it text? Like if I wanted my script to type out either "blue" or "red"

example: Set textToType to "The bard is wearing a {blue or red} tunic"

G4 iMac, Mac OS X (10.3.x), busted disk drive too lazy to fix

Posted on May 2, 2010 6:10 PM

Reply
6 replies

May 2, 2010 6:35 PM in response to eGeekee

okay, so I tried to test out the code and it doesn't seem to be working. This is my code:

tell application "TextEdit"
launch
repeat
delay (random number from 2 - 8)
some item of {"hello", "goodbye"}
end repeat
end tell




This doesn't seem to be doing anything at all, I also can't seem to put the "some item of {"hello", "goodbye"}" into a set textToType/keystroke command.

What am I doing wrong here? Is there a command to make either "hello" or "goodbye" typed that I'm not doing?

AppleScript 101 - How do I make random values?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.