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!

2
  • I think my problem might be with return, is there a better way to delay within a handler?
    – bookcasey
    Commented Apr 20, 2012 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. Commented Apr 20, 2012 at 23:52

1 Answer 1

9

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

0

You must log in to answer this question.

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