Notification from AppleScript Studio
- Comments:
- here.
Christoph asked me for some advice on how to get notification on iTunes track changes in a comment, I said I would write a bit of a tutorial on how I got it to work. First thing was to create an AppleScript Studio program - you will need to have the Developer Tools installed for this. Now, open the main.m file. It should look something like the following:
|
|
The file needs to have the following elements. At the start, the following imports are required:
|
|
This should be all of the imports that are required - although I also had stdio.h for a while for testing. After the declaration of the NSApplicationMain, I put the following in:
|
|
Copy and paste the stuff above - there is some that goes over the line in my browser, but it’s all there if you drag out the selection. You may need to change a couple of things depending on what you want to do. For instance, the @"tell application \nend tell" section needs to be the applescript code that is run whenever a new iTunes track is started, or iTunes is paused. You could fit the entire application into this place, but what I did was have a hidden button that this script “presses”, triggering the update process. Finally, I added the following declaration just after the first brace in the main function declaration:
|
|
This gets everything running. I would suggest putting the following into the applescript string to test it and see that it works:
|
|
You need to have \" whenever your script would have a ", and \n wherever it would have a newline.