I’m new to the world of applescripting using xcode and i have a couople of questions that you might be able to answer:
Is there a dictionary of applescript commands/classes you can use on certain NSObjects? (EX: a list of commands i can use to configure NStextField)
2a. what is wrong with the following code:
on clicked theObject
tell application "iTunes"
set nam to name of current track
set artis to artist of current track
set albu to album of current track
set bob to (nam & "-" & artis & "-" & albu)
end tell
get bob
set contents of text field "naa" of window "AtomTunes" to (bob as string)
end clicked
2b. as u might be able to tell…i’m making an iTunes Controller. What is the best applescript trigger to use to tell the text to update when the song changes?
thxs for the help!
Model: PowerBook
Browser: Safari 412
Operating System: Mac OS X (10.4)
hmm…that didn’t seem to work, i get the same error when i click the button that triggers the text field up date
here’s what i ended up with:
on clicked theObject
tell application "iTunes"
set nam to name of current track
set artis to artist of current track
set albu to album of current track
set bob to (nam & "-" & artis & "-" & albu)
end tell
get bob
set contents of text view 1 of scroll view "naa" of window "AtomTunes" to (bob as string)
end clicked
i’m not exactly sure what a scrolling view is…it’s not an NSTextView (which scrolls)
Model: PowerBook
Browser: Safari 412
Operating System: Mac OS X (10.4)
I don’t have any experience with scripting itunes, but it appears that everything is ok with your code. A #4 error usually means that you’re referencing an object incorrectly, or you are referencing an object that simply does not exist. First, the “get bob” is useless, and may be the cuplrit. Try deleting it, and if that doesn’t help, continue on.
Next, try replacing your example code with the following code (making sure to change ‘yourButton’ with the AS name of your button), which will simply test to see if your references are correct…
on clicked theObject
if name of theObject is "yourButton" then <-- if/else statement
set contents of text field "naa" of window "AtomTunes" to "Test Value"
end if
end clicked
It’s always best to use if/else statements in your handlers, referencing objects attached to them by name so you can effectively reuse the handler for all of your objects.
If that doesn’t work, then you have a problem with the naming (or existence) of one of your objects. Make sure that in the ‘applescript’ pane in interface builder your button and window are actually named “naa” and “AtomTunes”, respectively … remembering that case is important. Once that is confirmed, then something like the following should work…
on clicked theObject
tell application "iTunes"
set nam to name of current track
set artis to artist of current track
set albu to album of current track
set bob to (nam & "-" & artis & "-" & albu) as string
end tell
set contents of text field "naa" of window "AtomTunes" to bob
end clicked
If your problem is still not solved, you may have a corrupt nib or your connections may not be made properly. You may have to send one of us a copy to look at for us to find the problem.