PDA

View Full Version : AppleScript Studio help




Keytachi
May 11, 2008, 01:19 AM
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 (http://bbs.macscripter.net/viewtopic.php?id=23905)
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



lancestraz
May 11, 2008, 09:41 PM
Try this. Make sure to set the variable x to TRUE when your program launches.
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