i want to create “on _______” trigger for an applescript that updates every 10 seconds or so. This script would update the track name in my iTunes controller. How would i go about making the “on timer” script?
thxs
i want to create “on _______” trigger for an applescript that updates every 10 seconds or so. This script would update the track name in my iTunes controller. How would i go about making the “on timer” script?
thxs
“on idle” is what you’re after. Save the script as a “Stay Open” application, and it will stay open, idle, and cycle around after a specified number of seconds.
on idle
--do stuff
return 10 --number of seconds to delay
end idle
wait…wat i am trying to do is make a iTunes controller in xcode, will that work?. Wat i’m asking is, “is there a ‘on ________’ trigger that i can put in my NsTextField object script? (not a seperate app preferably)”
thxs for trying and for future help!
Carl was pretty much right on… you’re still looking for the idle handler, regardless of whether you’re in xcode or writing a simple script. Only the application object has the ability to run a timer… i.e. execute code at specified intervals. A text field can not be wired to do something in this manner. In fact, I don’t see how or why this would be beneficial. You can use a text field’s other handlers, such as ‘changed’ and ‘end editing’, to verify information entered and execute code accordingly. But, no, nstextfield cannot fire a timer.
In interface builder, click on the “File’s Owner” icon in the ‘MainMenu.nib’ window, under the “Instances” tab. Then, in the “Info” window under the “Applescript” pane (cmd-7)… check “idle” under “Application”, then select your script below. Then click “Edit Script”, and you should be taken to the script and the newly created ‘idle’ handler. In the handler, place any code you want to execute, and provide a return value at the end of the handler to define when to fire the handler again. For example…
on idle theObject
(* Insert code to execute here *)
return 5 --> how long (in seconds) before this handler is called again
end idle
That should take care of you. If not, you’re not asking the right question. Perhaps you could tell us WHY you want to use a timer attached to an nstextfield, so we can see if there may be a better way. Seems like idle should do just fine, as only the application object remains persistent in such a way that it could even be able to run a predictable timer.
j
thxs, that worked great!
I posted my answer without even noticing this was AS Studio forum Sorry.