Hi

I thought I would try to create a Spammer via Applescript, I have taken parts from around the web to help me out, so no credit is to me writing this from scratch myself, only in parts.

OK, the Spammer works fine, it follows through to the end, and there is a final option after it Spams asking if you would like to repeat the Spam... this is where I am having my problem, as basic and simple as it might be.

If you press "Yes Please" to continue, the Spam will continue after the set delay time, but if you press "No Thanks", it will quit but with an error. I'm not sure how to Cancel the operation when "No Thanks" is pressed???

If anyone might be able to help me out here, I think its a minor error on my part from lack of knowledge.

And yes I realise I could simply use a pre-made Spammer thats already out there or in a client, but that wont help me learn Applescript.

Simply copy and paste this into AppleScript Editor and press Compile, then Run it.

Code:
tell application "System Events"
	activate
	set textToSay to text returned of (display dialog "Write your Spam here:" default answer "" buttons {"Cancel", "Next"} default button 2 with title "Spammer")
	set int to text returned of (display dialog "Set Spammer Speed:
1 is Slow, 0.1 is Medium, and 0.01 is Fast. 
0.01 may be too fast for:
Browsers  
Online Games etc." default answer "0.1" buttons {"Cancel", "Next"} default button 2 with title "Spammer")
	set numoftimes to text returned of (display dialog "Number of messages to send" default answer "10" buttons {"Cancel", "Next"} default button 2 with title "Spammer")
	set theDelay to text returned of (display dialog "Set seconds till spammer starts" default answer "5" default button 2 with title "Spammer")
	display dialog "      Once you click 'OK' on the next dialog box
Click the application you want to Spam" with title "Spammer"
	display dialog "Starts in: " & theDelay default button 2 with title "Spammer"
	delay theDelay

	repeat
		repeat numoftimes times
			delay int
			keystroke return
			keystroke textToSay
			keystroke return
		end repeat
		display dialog "Repeat again?" buttons {"No Thanks", "Yes Please"} default button 1 with title "Spammer"
		if the button returned of the result is "No Thanks" then
			go to end
		else
			delay theDelay

		end if
	end repeat
end tell
You can also save this as an .app by going into: File - Export... :select File Format - Application :and check: Run Only :and then Save.
Change your icon if you have one you would prefer by right clicking your newly made .app and selecting: Get Info :and simply dragging and dropping your icon onto the icon at the top left of your Get Info window.