Keystroke repeater

Hi, I want to make a script or an automator flow, or just find a program that will let me repeat keystrokes. I want to cut every 13th frame in a clip in iMovie, so I would want something that would allow me to automate hitting the right button thirteen times and then apple-T. Is this possible with apple scripts or does anyone know how I could go about doing this? I’ve searched on google for over an hour and have come up with nothing…
any help is appreciated! thanks

Hi,

Try this:

set myRight to ASCII character 29 -- Right arrow, change to 28 for left arrow.
tell application "System Events"
	tell application "iMovie" to activate
	repeat with x from 1 to 13
	keystroke myRight, myRight
	end repeat
	keystroke "t" using command down
end tell

Best wishes

John M

Hey, thanks a lot for the script! When I try to compile it though, it gives me an error: "Expected end of line, but found “,” "… and it highlights the comma in the following line:
“Keystroke myRight, myRight”
any idea what I should do to fix this?

Nevermind, I took out the second myRight and it worked. any way I can make the script run repeatedly until I tell it to stop?

You could put it into an infinite repeat and then force quit it, but a better way would be to specify how many times to run it. How about this - you can select to run it 100, 50 or 10 times. You can change these if bigger or smaller options would make more sense.


tell application "System Events"
set InputNum to the button returned of (display dialog "How times?" buttons {"10", "50", "100"} default button "100")
set NumOfTimes to InputNum as real
	tell application "iMovie" to activate
	repeat with y from 1 to NumOfTimes
		repeat with x from 1 to 13
			key code 124  --right arrow
		end repeat
		keystroke "t" using command down
	end repeat
end tell

Model: Mac G5
Operating System: Mac OS X (10.3.9)