Alright.
I have an applescript that automatically sends information about my current iTunes track to two seperate Ventrillo programs. When I first ran it from the script editor, it worked fine, great, perfect. As soon as I saved it as an application and then ran it, however, somehow it automatically changed the script! It opened the wrong copy of Ventrillo first, then gave me an error.
So, I reopened the script to see what happened, and low and behold, it changed the name of the application in one of my instructions.
tell application “Ventrilo” magically turned into tell application “TeamVent”! Can anyone give me some insight on exactly how to tell Applescript to, well, just run the script that I told it to instead of it’s own version? I mean, what the hell
Here’s the script before I save it (the important part is near the end):
(*
"Current to Clipboard" for iTunes
written by Doug Adams
dougadams@mac.com
v1.5 September 23 2004
-- handles tracks in streams better
-- generally updated for modern iTunes
v1.0 Novemeber 13, 2001
-- initial release
Get more free AppleScripts and info on writing your own
at Doug's AppleScripts for iTunes
http://www.malcolmadams.com/itunes/
*)
tell application "iTunes"
if player state is not stopped then
set ct to current track
set station_name to ""
set {nom, art, alb} to {"", "", ""}
tell ct
try
if artist is not "" and artist is not missing value then
set art to (" by " & artist)
end if
end try
try
if name is not "" then
set nom to name
else
set nom to "unknown"
end if
end try
try
if album is not "" then
set alb to ("Album: " & album)
else
set alb to "Album: Unknown"
end if
end try
end tell
-- nevermind all that if I can get radio stream info
-- also, current stream title may not return a value that works with this parsing
try
if (class of ct is URL track) and (get current stream title) is not missing value then
set station_name to (nom & " - ") -- you can use this if you want
set {art, nom} to my text_to_list((get current stream title), " - ")
set art to " by " & art
end if
end try
-- basic info (feel free to format your own message!)
set the clipboard to (station_name & "\"" & nom & "\"" & art)
tell application "Ventrilo" to activate <------HERE'S WHAT PART GETS CHANGED
tell application "System Events"
tell application process "Ventrilo"
click button "Comment" of window "Ventrilo"
delay 1
click menu item "Paste" of menu 1 of menu bar item "Edit" of menu bar 1
delay 1
click button "OK" of window "Comment"
end tell
end tell
set the clipboard to alb
activate application "TeamVent"
tell application "System Events"
tell application process "TeamVent"
click button "Comment" of window "Ventrilo"
delay 1
click menu item "Paste" of menu 1 of menu bar item "Edit" of menu bar 1
delay 1
click button "OK" of window "Comment"
end tell
end tell
end if
end tell
on text_to_list(txt, delim)
set saveD to AppleScript's text item delimiters
try
set AppleScript's text item delimiters to {delim}
set theList to every text item of txt
on error errStr number errNum
set AppleScript's text item delimiters to saveD
error errStr number errNum
end try
set AppleScript's text item delimiters to saveD
return (theList)
end text_to_list
Now, here’s the script AFTER I save it as an application:
....clipped....
-- basic info (feel free to format your own message!)
set the clipboard to (station_name & "\"" & nom & "\"" & art)
tell application "TeamVent" to activate <--------CHANGED TO "TEAMVENT".
tell application "System Events"
tell application process "Ventrilo"
click button "Comment" of window "Ventrilo"
delay 1
click menu item "Paste" of menu 1 of menu bar item "Edit" of menu bar 1
delay 1
click button "OK" of window "Comment"
end tell
end tell
set the clipboard to alb
activate application "TeamVent"
tell application "System Events"
tell application process "TeamVent"
click button "Comment" of window "Ventrilo"
delay 1
click menu item "Paste" of menu 1 of menu bar item "Edit" of menu bar 1
delay 1
click button "OK" of window "Comment"
end tell
end tell
end if
end tell
...clipped...
Since I had to call specific application processes, I had to change the process names of one of the duplicate Ventrilo programs. I did this by changing the engine application in the MacOS folder under Show Package Contents, and then updating the Info.plist file in the same package folder. I also changed the name of the package app. They were all changed to TeamVent.
The other Ventrilo application was left alone with the name Ventrilo for both the appllication name and the application process name.
So, yeah, if anyone could help me, that’d be awesome because I’m sure stuck on what to do now.
Thanks!
AppleScript: 1.10.6
Browser: Firefox 1.5.0.7
Operating System: Mac OS X (10.4)