7

I want to make a small application that will type the number 1, wait an interval, type the number 2, wait an interval, type number 3, wait an interval, etc.

This works for typing one number over and over:

on idle
    tell application "System Events"
        key code 18
    end tell
    return 2
end idle

But I'm struggling to get more than number to work:

on idle
    tell application "System Events"
        key code 18
    end tell
    return 2
    tell application "System Events"
        key code 19
    end tell
    return 2
end idle

This doesn't work. Nor does this:

on idle
    tell application "System Events"
        key code 18
        return 2
        key code 19
        return 2
    end tell
end idle

I don't know what else to try. Thank you!

  • I think my problem might be with return, is there a better way to delay within a handler? – bookcasey Apr 20 '12 at 23:17
  • 4
    Related tip: you can use keystroke "1" instead of key code. Keystroke lets you type in any text and have it typed for you. – Nathan Greenstein Apr 20 '12 at 23:52
9

Try using delay 2 instead of return 2return exits from the loop!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .