Simple Script, keystrokes...Need Help

I am currently playing through a video game on an Emulator named Snes9x, and I need to be able to repeat keystrokes, but honestly, have no idea where to start with Applescript. If anyone could put a script together, that would be great. It needs to be able to execute 3 keystrokes, one after the other, so…: “A” then wait a second, then “B”, then wait a second, then “C”. Then repeat in an infinite loop, or at least a loop with a large enough number to occupy quite some time (try 5 hours). Thanks for any help that you can give!

http://www.cesoft.com/products/qkx.html

this works with text edit i did the math and it seems that there are 6000sec X 3sec = 5 hours
the second script will exit the loop at any time if the application is not the frontmost window.

set counta to 1
tell application "System Events"
	tell application process "textedit"
		set frontmost to true
			repeat until counta is 6000
				keystroke "a"
				delay 1
				keystroke "b"
				delay 1
				keystroke "c"
				delay 1
				set counta to counta + 1
			end repeat
		end tell
end tell

second one


tell application "TextEdit"
	activate
end tell
set counta to 1
tell application "System Events"
	tell application process "textedit"
		set frontmost to true
		
repeat until counta is 6000
			if frontmost is false then
				exit repeat
			end if
			keystroke "a"
			delay 1
			if frontmost is false then
				exit repeat
			end if
			keystroke "b"
			delay 1
			if frontmost is false then
				exit repeat
			end if
			keystroke "c"
			delay 1
			set counta to counta + 1
		end repeat
	end tell
end tell