2

I have something like

tell application "System Events"

set x to "x"

delay 1

repeat

delay 3

keystroke x

end repeat

set y to "y"

delay 1

repeat

delay 5

keystroke y

end repeat

end tell

but it never keystrokes y, it only keystrokes x, and when I reverse it it waits 5 second to do y first, but I just want x to repeat every 3 seconds and y every 5 seconds.

2

You didn't specify how many times the loop will run. You can try something like this:

tell application "System Events"
    set x to "x"
    repeat 3 times
        keystroke x
        delay 3
    end repeat
    set y to "y"
    repeat 5 times
        keystroke y
        delay 5
    end repeat
end tell
  • But I want to go them consecutively, like it does x every 3 seconds, then y every 5 seconds, then it repeats again. – astr0aster Jul 18 '17 at 19:50
  • Ok never mind I figured it out, you have to add the keystrokes in the same repeat. I'm so stupid ahaha – astr0aster Jul 18 '17 at 19:53
2

I figured it out, you have to add the keystrokes to the same repeat

so

repeat

keystroke "x"

delay 3

keystroke "y"

delay 5

end repeat

You must log in to answer this question.

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