Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Keytachi

macrumors regular
Original poster
Sep 14, 2006
161
0
hi everyone! i started to take my first steps on ASS, after doing some lousy apps on AS :)P), and i need some help.
My goal is to make an application that, when i press the button "start" it starts a loop. when i press the button "stop" it stops the loop.

this is what i got so far (i took the "if ChosenButton..." from here
Code:
on clicked theObject
	set ChosenButton to the name of theObject
	if ChosenButton is {"Start"} then
		repeat
			tell window of theObject
				tell application "System Events"
					tell application "TextEdit" to activate
					keystroke " "
					delay 10
				end tell
			end tell
		end repeat
	end if
	if ChosenButton is {"Stop"} then
		exit repeat
	end if
end clicked

but with this script, i get a -1708 error :(
i had something different (on idle handler and a variable that only started the on idle if i pressed the start button, but i was never able to make it stop the loop).

Anyone has any ideas?

Thanks, Keytachi


P.S.
For testing purposes i'm using TextEdit and "a"
and yes, i do have assistive devices allowed
 
Try this. Make sure to set the variable x to TRUE when your program launches.
Code:
on clicked theObject
	set ChosenButton to the name of theObject
	if ChosenButton is {"Start"} then
		repeat while x is true
			tell window of theObject
				tell application "System Events"
					tell application "TextEdit" to activate
					keystroke " "
					delay 10
				end tell
			end tell
		end repeat
	end if
	if ChosenButton is {"Stop"} then
		set x to false
	end if
end clicked
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.