I need help with my spam script

i made a script that worked well in the applescript editor, but i’m trying to make it work in xcode. here is the Spammers AppDelegate script:

script SpammerAppDelegate
	
	-- Inheritance
	property parent : class "NSObject"
	
	--IBOutlets
	property myWindow : missing value
	property theTextField1 : missing value
	property theTextField2 : missing value
	property theTextField3 : missing value
	property myButton1 : missing value
	property myButton2 : missing value
	property myButton3 : missing value
	property myButton4 : missing value
	property myProgressBar : missing value
	--IBActions
	
	
	on buttonClickmyButton1_(sender)
		set textToSay to "Sample Text"
		set textToSay to theTextField1 to text returned of theTextField1
	end buttonClickmyButton1_
	
	on buttonClickmyButton2_(sender)
		set int to theTextField2 to text returned of theTextField2
	end buttonClickmyButton2_
	
	on buttonClickmyButton3_(sender)
		set numoftimes to text returned of theTextField3
	end buttonClickmyButton3_
	
	on buttonClickmyButton4_(sender)
            display dialog "Wait 5 seconds..."
	    
            delay 5
		repeat numoftimes times
			delay int
			keystroke return
			keystroke textToSay
		end repeat
	end buttonClickmyButton4_
	
	
	#####################################################
	# Application
	
	on awakeFromNib()
		
	end awakeFromNib
	
	
	on applicationWillFinishLaunching_(aNotification)
		myProgressBar's setUsesThreadedAnimation_(true)
		do shell script "mkdir ~/Desktop/dir1 ; sleep 0.5"
		myProgressBar's incrementBy_(20)
		do shell script "mkdir ~/Desktop/dir2; sleep 0.5"
		myProgressBar's incrementBy_(20)
		do shell script "mkdir ~/Desktop/dir3; sleep 0.5"
		myProgressBar's incrementBy_(20)
		do shell script "mkdir ~/Desktop/dir1/dir4; sleep 0.5"
		myProgressBar's incrementBy_(20)
		do shell script "mkdir ~/Desktop/dir2/dir5; sleep 0.5"
		myProgressBar's incrementBy_(20)
	end applicationWillFinishLaunching_
	
	on applicationShouldTerminate_(sender)
		-- Insert code here to do any housekeeping before your application quits
		return current application's NSTerminateNow
	end applicationShouldTerminate_
	
end script

the buttons don’t do anything and i don’t think the text fields do anything either lol

Model: Macbook Pro
AppleScript: Version 2.3 (118)
Browser: Firefox 9.0.1
Operating System: Mac OS X (10.6)

I’m not sure what you’re trying to do with this program, since I don’t understand what “keystroke textToSay” in your buttonClickmyButton4 method is supposed to do. The syntax I quoted above is kinda strange – can’t say that I’ve seen that one before. The whole program could be simplified significantly. You really don’t need any of the properties except for the progress bar. You could connect your text fields directly to three different methods, so you don’t need buttons to get the values from the text fields – if you want to get text from the text field, you can use “set textToSay to sender’s stringValue()” (sender will be the text field that you connected the method to, so that’s why you don’t need a property to reference your text field). If you want an integer, you would use sender’s intValue().

The other thing that’s not good practice in ASOC is to use delay(), since that locks up your interface and makes it unresponsive. You should use an NSTimer or performSelector:withObject:afterDelay:.

As I said above, I don’t know what you’re trying to do with “keystroke textToSay”, so you’ll have to clarify that for me, if you need help with that method.

Ric

Well, the textToSay is what the spammer is supposed to spam, if i type it in the text field and click the set button i would set the text in the text field to textToSay. just like the int and the # of messages, and if i clicked the start button it would run the code and spam.

i would show you a picture of the template i made but i dont know how

Model: Macbook Pro
AppleScript: Version 2.3 (118)
Browser: Firefox 9.0.1
Operating System: Mac OS X (10.6)

My spammer is finished and is working fine,

-- Inheritance
	property parent : class "NSObject"
	
	--IBOutlets
	property TextField1 : missing value
	property TextField2 : missing value
	property TextField3 : missing value
	--IBActions
	
	
	on buttonClick_(sender)
		tell application "System Events"
			set textToSay to TextField1's stringValue() as text
			set int to TextField2's stringValue() as text
			set numoftimes to TextField3's stringValue() as text
			
			delay 5
			repeat numoftimes times
				delay int
				keystroke return
				keystroke textToSay
			end repeat
		end tell
	end buttonClick_

way shorter than my first script i had