AppleScript error with iTunes: Can't get window 'iTunes' of class pcap ...

Hi there. I'm working on a script that posts iTunes track names to Campfire based on the AirPlay device in use. I've been getting a "Can't get window 'iTunes' of <<class pcap>> 'iTunes' of application 'System Events'" and was hoping someone might see an obvious answer. The error pops up randomly. Some machines receive the error much more often than others. Here's the code:
global current_track
global last_track
global campfire_token
global airplay_device
global campfire_room
global current_device
(* Begin user defined settings ************)
set campfire_token to "123456" (* Your Campfire API authentication token *)
set airplay_device to "Apple TV" (* The name of your AirPlay device *)
set campfire_room to "https://yourorg.campfirenow.com/room/123456/speak.xml" (* The Campfire room you'd like to post to *)
(* End user defined settings *************)
set current_track to ""
set current_device to ""
set last_track to ""
on idle
          if application "iTunes" is running then
                    tell application "iTunes"
                              if player state is playing then
                                        tell application "System Events"
                                                  tell application "iTunes"
                                                            set minimized of front browser window to false (*This AppleScript can only function when iTunes is not minimized.  *)
                                                            delay 2
                                                            set visible of front browser window to true
                                                            delay 2
                                                            set current_track to current track
                                                  end tell
                                                  delay 2
                                                  set current_device to the description of button 8 of window "iTunes" of application process "iTunes" of application "System Events"
                                        end tell
                                        delay 2
                                        if current_track is not equal to last_track then
                                                  if current_device as string is equal to airplay_device & " AirPlay" then
                                                            tell application "iTunes"
                                                                      set current_track to current track
                                                                      tell current_track
                                                                                set trackName to (name)
                                                                                set artistName to (" :: " & artist)
                                                                                set albumName to (" :: " & album)
                                                                      end tell
                                                                      set track_info to (trackName & artistName & albumName) as string
  (* Replace apostrophes *)
                                                                      set search_string to "'"
                                                                      set replacement_string to "&#39;"
                                                                      set AppleScript's text item delimiters to the search_string
                                                                      set the item_list to every text item of track_info
                                                                      set AppleScript's text item delimiters to the replacement_string
                                                                      set track_info to the item_list as string
                                                                      set AppleScript's text item delimiters to ""
  (* Replace quotation marks *)
                                                                      set search_string to "\""
                                                                      set replacement_string to "&#34;"
                                                                      set AppleScript's text item delimiters to the search_string
                                                                      set the item_list to every text item of track_info
                                                                      set AppleScript's text item delimiters to the replacement_string
                                                                      set track_info to the item_list as string
                                                                      set AppleScript's text item delimiters to ""
                                                                      set shellCommand to ("curl -u " & campfire_token & ":X -H 'Content-Type: application/xml' -d '<message><type>TextMessage</type><body>" & track_info & "</body></message>' " & campfire_room)
                                                                      set shellCommand to shellCommand as string
  do shell script shellCommand
  (*display dialog shellCommand*)
  (*log "Posting to Campfire:" & shellCommand*)
                                                            end tell
                                                            delay 2
                                                  end if
                                        end if
                                        set last_track to current_track
                              end if
                              return 1
                    end tell
          end if
end idle
Thanks for your help. Any suggestions are appreciated!

well, for information's sake, the cleaned-up script looks like this:
(* Begin user defined settings ************)
property campfire_token : "123456" (* Your Campfire API authentication token *)
property airplay_device : "Apple TV" (* The name of your AirPlay device *)
property campfire_room : "https://yourorg.campfirenow.com/room/123456/speak.xml" (* The Campfire room you'd like to post to *)
(* End user defined settings *************)
global current_track, last_track, current_device
on run
  (* init at runtime*)
          set current_track to ""
          set current_device to ""
          set last_track to ""
end run
on idle
          if application "iTunes" is not running then return 60
          tell application "iTunes"
                    if (player state is not playing) or (current track is equal to last_track) then return
                    set last_track to current track
                    set minimized of front browser window to false
                    set visible of front browser window to true
                    set current_device to my getDevice()
                    if current_device as string is not equal to airplay_device & " AirPlay" then return
                    set track_info to my mungeText({name, artist, album} of last_track, "", "::")
                    set track_info to my mungeText(track_info, "'", "&#39;") -- Replace apostrophes
                    set track_info to my mungeText(track_info, "\"", "&#34;") -- Replace quotation marks
                    set shellCommand to ("curl -u " & campfire_token & ":X -H 'Content-Type: application/xml' -d '<message><type>TextMessage</type><body>" & track_info & "</body></message>' " & campfire_room)
  do shell script (shellCommand as string)
  (*display dialog shellCommand*)
  (*log "Posting to Campfire:" & shellCommand*)
                    return
          end tell
end idle
on getDevice()
          tell application "System Events"
                    tell process "iTunes"
                              return description of button 8 of window "iTunes"
                    end tell
          end tell
end getDevice
on mungeText(itxt, stxt, rtxt)
          set tid to AppleScript's text item delimiters
          if class of itxt is text then
                    set AppleScript's text item delimiters to stxt
                    set itxt to text items of itxt
          end if
          set AppleScript's text item delimiters to rtxt
          set otxt to itxt as text
          set AppleScript's text item delimiters to tid
          return otxt
end mungeText
I'm positive there's a better way to check if AirTunes is the active device (maybe by seeing if the current playlist is a device playlist, and checking the source name?), but I don't have any way to test that.

Similar Messages

  • Can't get windows 8.1 with dual boot for fedora (linux) . system is UEFI .

    Can't get  windows 8.1 with  dual boot for fedora (linux) . system is UEFI .

    Hi,
    Any update here?
    We may seek help at Fedora forum as Milos suggested, if convenient we could share the related thread link here for reference.
    In addition, please also check the information in the similar thread:
    Dual Boot Windows 8 and Linux?
    Best regards
    Michael Shao
    TechNet Community Support

  • I continue to get r6025 runtime error with iTunes version 10.6.3.25.  Have uninstalled and reinstalled twice.  Happens when I search in iTunes Store.  Ideas to fix?

    I continue to get r6025 runtime error with iTunes version 10.6.3.25.  Have uninstalled and reinstalled twice.  Happens when I search in iTunes Store.  Ideas to fix?

    Hi,
    got it fixed! My Son had both files on his Win7 iTunes installation. Never mind he had no issues whith ths iTunes and iPhone Sync. So I checked my other Win XP PC, where I don't have this problem syncing my ipad, and surprise. Both files do NOT show up on this PC. So I renamed the iTunesPhotoProcessor.exe I found under c:\program file\iTunes and synced again my iPhone and it went through without any error. So the problem might be and unremoved iTunesPhotoProcessor.exe or the missing iTunesPhotoProcessor.dll under the iTunes install root folder and this even if I had checked that the folder was completely removed during iTunes unistall.
    Please try yourselve and just rename the iTunesPhotoProcessor.exe to iTunesPhotoProcessor.exe_ under c:\program file\iTunes or get a copy of the missing iTunesPhotoProcessor.dll and cp to c:\program file\iTunes.

  • Hi, I've been trying for days to download Windows support software via Bootcamp assistant, but it always failed with message 'Can't install Windows Support Software because it is not currently available from the Software update server.' Any advice welcome

    Hi,
    I've been trying for days to download Windows support software via Bootcamp assistant but it always fails with message 'Can't install windows software because it is not currently available from the software update server.'
    Anyone else had problems or success with this?
    Thanks in advance.

    9thdoc wrote:
    I'm getting a similar but distinct error message in snow leopard: Download could not continue. "The windows support software is not available" and have no original snow leopard instal disc with me.
    Your issue is completely different. You are running Snow Leopard. There is no download for Windows Support software for Snow Leopard, hence the error you see. Snow Leopard Windows Support software is on the Snow Leopard installation disk.
    You need the Snow Leopard installation disk or a replacement for it.

  • I have several episodes of a TV show that say "download error, tap to retry" and when I do it just repeats that error message.  Can I get it to work? If not can I get reimbursed for the episodes I'm missing?  I'm using an iPad one which has worked fine B4

    I have several episodes of a TV show where it says download error, tap to retry and when I do it repeats the error message.  Can I get it to work or get reimbursed for the ones I'm missing?  I'm using an iPad 1 which has worked fine for all the others.

    Hi AlpineJean,
    I'm sorry to hear you are having issues downloading some episodes to your iPad.
    I would first suggest you sign out of your iTunes account on your iPad, restart the device and sign back in.
    Settings > iTunes & App Stores > Tap on your Apple ID account > Tap Sign Out
    Click on the link below for additional troubleshooting steps with more details and screenshots.
    I've quoted some helpful highlights for you:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    To view or download previously purchased:
    TV Shows on iOS
    Open the iTunes Store on your device.
    Make sure you are signed in with the same Apple ID you used for the original purchase.
    Tap More from the bottom navigation bar.
    Tap TV Shows.
    Locate the TV show episode or series you would like to download.
    Once you've located the TV shows you are looking for, tap the download button.
    The TV show will begin downloading.
    Previous purchases may be unavailable if they have been refunded or are no longer on the iTunes Store. Downloading previously purchased movies and TV shows requires iTunes 10.6 or later.
    If this does not resolve your issue, please follow these instructions for support from the iTunes Store:
    How to report an issue with your iTunes Store, App Store, Mac App Store, or iBookstore purchase
    Find the email receipt for your purchase.
    Click Report a Problem under the app that is having the issue.
    When prompted, enter the Apple ID and password you used to purchase the item, then click Report a Problem.
    Click Report a Problem next to the item you are having an issue with.
    From the Choose Problem dropdown menu, choose the appropriate issue.
    Follow the onscreen instructions and—if prompted—type a description of the problem into the text field.
    Click Submit to have your issue reviewed.
    Have a great day!
    - Judy

  • HT2693 it said activation Error,and i can't get in and see my serial number. what can i do?

    it said activation Error,and i can't get in and see my serial number.

    Hi tristanbolo,
    Thanks for visiting Apple Support Communities.
    If your iPad mini powered off unexpectedly and will not power on, try these steps, which apply to the iPad mini as well:
    iPhone: Hardware troubleshooting
    http://support.apple.com/kb/TS2802
    Will not turn on, will not turn on unless connected to power, or unexpected power off
    Verify that the Sleep/Wake button functions. If it does not function, inspect it for signs of damage. If the button is damaged or is not functioning when pressed, seek service.
    Check if a Liquid Contact Indicator (LCI) is activated or there are signs of corrosion. Learn about LCIs and corrosion.
    Connect the iPhone to the iPhone's USB power adapter and let it charge for at least ten minutes.
    After at least 30 minutes, if:
    The home screen appears: The iPhone should be working. Update to the latest version of iOS if necessary. Continue charging it until it is completely charged and you see this battery icon in the upper-right corner of the screen . Then unplug the phone from power. If it immediately turns off, seek service.
    The low-battery image appears, even after the phone has charged for at least 20 minutes: See "iPhone displays the low-battery image and is unresponsive" symptom in this article.
    Something other than the Home screen or Low Battery image appears, continue with this article for further troubleshooting steps.
    If the iPhone did not turn on, reset it while connected to the iPhone USB power adapter.
    If the display turns on, go to step 4.
    If the display remains black, go to next step.
    Connect the iPhone to a computer and open iTunes. If iTunes recognizes the iPhone and indicates that it is in recovery mode, attempt to restore the iPhone. If the iPhone doesn't appear in iTunes or if you have difficulties in restoring the iPhone, see this article for further assistance.
    If restoring the iPhone resolved the issue, go to step 4. If restoring the iPhone did not solve the issue, seek service.
    Best,
    Jeremy

  • I can't get Window's Media Player to recognize my new ipod shuffle.  Does anyone have a solution/, I can't get Window's Media Player to recognize my new ipod shuffle.  Does anyone have a solution?

    I can't get Window's Media Player to "recognize" my new ipod shuffle.  Does anyone have a solution?  When I pull the ipod shuffle up in Devices and Printers, it says it needs Troubleshooting, but the Troubleshooting provides no solution.

    Windows Media Player?  As far as I know, that won't work.  You need to install iTunes
    http://www.apple.com/itunes/
    That will install the software you need to use your shuffle with your computer.

  • HT4796 I can not get windows migration assistant to work on my Sony Viao running windows 7

    I can not get windows migration assistant to work with Sony Laptop running windows 7.

    Hello,
    - What did you do so far ?
    - Do you have any error messages ?
    You will find a lot of useful informations on this page :
    http://support.apple.com/kb/HT4796

  • My iPod Classic is not detected by my Windows 8 computer when I connect it via USB port.  How can I get windows to detect this device?

    My iPod Classic is not detected by my Windows 8 computer when I connect it via USB port.  How can I get windows to detect this device?  A message from windows says: the device has malfunctioned.

    Try TS1363: iPod: Appears in Windows but not in iTunes.
    See also Corrupt iPod classic.
    tt2

  • How can I get Windows (v7 x64) to open in Dreamweaver (CS5) if I right click it?

    Hi
    How can I get Windows (v7 x64) to open in Dreamweaver (CS5) if I right click it?
    None of the normal mechanisms of setting an application to be the DEFAULT application for the .HTML file type seem to work...
    Extremely irritating.
    J

    Jon Fritz II wrote:
    So when you right-click an .html file and choose Open With, what are you seeing?
    Is the check box for "Always use the selected program to open this kind of file" checked?
    A list of various "recommended applications" but not including Dreamweaver. It's not in the list of Other Applications either. And if I browse for it, my selection of dreamweaver.exe is flatly ignored without message.
    >Is the check box for "Always use the selected program to open this kind of file" checked?
    Jon Fritz II wrote:
    So when you right-click an .html file and choose Open With, what are you seeing?
    Is the check box for "Always use the selected program to open this kind of file" checked?
    A list of various "recommended applications" but not including Dreamweaver. It's not in the list of Other Applications either. And if I browse for it, my selection of dreamweaver.exe is flatly ignored without message.
    > Is the check box for "Always use the selected program to open this kind of file" checked?
    Yes.
    J

  • If I use Bootcamp, can I get Windows viruses on my Mac?

    I am using Mac OS X 10.8.3. I am about to install Windows 7 on my iMac with Bootcamp. Can I get Windows virus on my Mac because of Bootcamp?

    If you do, it'll only affect the Windows partition of your hard drive.
    If you feel really worried, I'd suggest running Windows in a virtual machine using Parallels or similar. You can set things up so that there's no access to your Mac from the virtual machine and, if the VM gets a problem, you can just delete it.

  • Help Mac-brothers: can't get Windows to install

    Thanks for reading. No matter how I try, I just can't get Windows (either Vista or XP Pro) installed on my Macpro! I made a partition with Bootcamp, started the installationprocess, on asking where to put Windows I selected the Bootcamp-partition and reformatted it. No matter what I do, it keeps telling me that it can't install Windows becouse it does not see a suitable sytem volume. what am I doing wrong? It drives me mad. Any help is welcome. Thank in advance!

    Vista x64 doesn't like the NTFS partition BootCamp creates, so you have to delete and format, then reboot off the Vista DVD again.
    And sometimes it only works if OS X is nowhere to be found (removed).
    I always put Windows Vista on its own hard drive. And pull my OS X drive.
    Having four drive bays, very easy.
    Never tried with Pro. And in fact, I only 'tested' BootCamp Assistant once or twice. I just format a drive as FAT and then let Vista format it. BCA isn't necessary, and you can install the Apple drivers later when Windows is fully installed, patched, updated, and running fine.

  • Where can i get windows 7 home basic for my ideapad z570?

    HelloMy hard disk got corrupted and i had to replace it with a new one. my laptop came with preinstalled windows 7 home basic and a product key at the back. with one key recovery, the backup of os was in the older hard disk which can not be recovered. how can i install the older windows 7 version with the given product key?

    Penguin555 wrote:
    Penguin555 wrote:
    where can I get windows 7 keyboard and mouse drivers for bootcamp?
    I have installed Windows 7 in a boot camp partition. I can only use usb keyboard and mouse by booting Windows intyo safe mode, and I am totally unable to use my Apple wireless keyboard and mouse. How do I resolve this?
    I'm running Lion - 10.7.2. Boot Camp Assistant fails to download drivers - that issue has been going on for some time, and has been reported by others as well.
    But that answers your question.  You get the drivers by using BCA to download them.  Your inability to download the drivers is a separate issue than not being able to use your wireless keyboard.
    While some people may have issues downloading the drivers, many others have successfully downloaded the drivers.  I have downloaded them fine on several different Macs.  It may take a long time, depending on the speed of your internet connection.  Mine took over 3 hours.
    Regardless, you need to download the drivers using Boot Camp Assistant.  Try again, and if you still have problems, start a new thread and provide as much details as possible to describe what your seeing so that we don't have to go through this back-and-fourth, and you'll get your answer quicker.

  • Satellite A200-1M4: Can I get Windows Vista separately?

    Hello
    When I install Product Recovery CD, it installs Windows Vista and many programs I don't need.
    I want just to install Windows Vista (even excluding drivers).
    So, can I get Windows Vista (Home Premium) setup separately?
    Thanks

    Hello
    There is no separately setup. You are not alone with this opinion and nobody force you to use all installed stuff. I remove also all stuff I do not need.
    Install OS using recovery CD, download all Microsoft updates to be sure everything is up to date and then remove all stuff you do not need. Believe me I do the same.
    Just for example - I have one Satellite delivered with WXP and I have done follow:
    1. Installed OS using delivered recovery DVD
    2. Installed all Microsoft updates
    3. Removed all applications I do not need
    4. Installed all applications I need for work (Office, Nero and so on)
    5. Installed Norton Ghost
    6. Created my own recovery image
    Now I can reinstall my own OS and after just 30 minutes everything is there. In case of some virus or any other strange issue I have install OS again (on partition C). All saved data on partition D are still there and can be used after image installation.

  • Where can I get Window's software for my Macbook Pro? I'm trying to run ARCview. However, it requires Windows. I'm trying Bootcamp. but, it isn't recognising the disk that I currently have.

    Where can I get Window's software for my Macbook Pro? I'm trying to run ARCview. However, it requires Windows. I'm trying Bootcamp. but, it isn't recognising the disk that I currently have.

    Maybe because it's not a 'genuine' retail version? Many OEM versions just don't work - and I've no idea which flavor of Win7 your friend downloaded. Obviously one that Boot Camp doesn't recognize. Best to just pony up the cash for a full retail version, of some flavor - and use it. You COULD, of course, download the 14-day trial version of Parallels Desktop and see if you can install Win7 as a virtual machine... it might or might not work. Boot Camp just isn't finding the resources it needs on the copy you have - try Parallels and if that doesn't work just purchase a retail (or student discounted) version.
    Clinton

Maybe you are looking for