state of checkboxes?

ok so in the following script for my lyrics grabber the point is that it has two options. there is a checkbox which says “Listen to iTunes” what it does is gets the lyrics of the current song in iTunes. Unfortunatly it doesn’t update when the song changes…this is probably because I need an on idle handler. I don’t know how to check to see if the check box is checked off or not because it is considered a button…its confusing i know…well here is the code so far.

-- Serenade.applescript
-- Serenade

-- Created by Collin on 11/08/06.
-- Copyright 2006 Hendosoft. All rights reserved.
property cur_track : ""
property cur_song : ""
property cur_artist : ""
property theLyrics : ""
on clicked theObject
   if the name of theObject is equal to "listen" then
       set buttonstate to enabled of button "lyric_search" of window "mainWindow"
       if buttonstate is equal to true then
           set enabled of button "lyric_search" of window "mainWindow" to false
       else
           set enabled of button "lyric_search" of window "mainWindow" to true
       end if
       
       using terms from application "iTunes"
           tell application "iTunes"
               if exists (database ID of current track) then
                   set cur_track to the current track
                   set cur_song to the name of the current track
                   set cur_artist to the artist of the current track
               end if
           end tell
       end using terms from
       set theSong to cur_song
       set theArtist to cur_artist
       using terms from application "iTunes"
           tell application "iTunes"
               set theLyrics to the lyrics of cur_track
           end tell
       end using terms from
       tell window "mainWindow"
           set the contents of text view "lyrics" of scroll view "lyrics" to theLyrics
       end tell
       
       if theLyrics is equal to "" then
           set theSong to edittext(theSong)
           set theArtist to edittext(theArtist)
           set ASTID to AppleScript's text item delimiters
           set AppleScript's text item delimiters to {" "}
           set theSong to text items of theSong
           set theArtist to text items of theArtist
           
           set AppleScript's text item delimiters to {"-"}
           set theSong to theSong as Unicode text
           set theArtist to theArtist as Unicode text
           set AppleScript's text item delimiters to {""}
           
           get "http://www.lyricsdir.com/" & theArtist & "-" & theSong & "-lyrics.html"
           do shell script "/usr/bin/curl --user-agent '' " & quoted form of result
           set theLyrics to result
           
           set AppleScript's text item delimiters to {"<div id=\"lyrics\">"}
           set theLyrics to (last text item of theLyrics) as Unicode text
           
           set AppleScript's text item delimiters to {"</div>"}
           set theLyrics to first text item of theLyrics
           
           set AppleScript's text item delimiters to {"<br />"}
           set theLyrics to text items of theLyrics
           
           set AppleScript's text item delimiters to {""}
           set theLyrics to text 2 thru -1 of (theLyrics as Unicode text)
           
           set AppleScript's text item delimiters to ASTID
           tell window "mainWindow"
               set contents of text view "lyrics" of scroll view "lyrics" to theLyrics
           end tell
           using terms from application "iTunes"
               tell application "iTunes"
                   set cur_track to the current track
                   set the lyrics of cur_track to theLyrics
               end tell
           end using terms from
       end if
   else if the name of theObject is equal to "search_btn" then
       set songtext to the contents of text field "song_title" of drawer "search_drawer" of window "mainWindow" as string
       set artisttext to the contents of text field "song_artist" of drawer "search_drawer" of window "mainWindow" as string
       set theSong to songtext
       set theArtist to artisttext
       set theSong to edittext(theSong)
       set theArtist to edittext(theArtist)
       set theSong to songtext
       set theArtist to artisttext
       
       set ASTID to AppleScript's text item delimiters
       set AppleScript's text item delimiters to {" "}
       set theSong to text items of theSong
       set theArtist to text items of theArtist
       
       set AppleScript's text item delimiters to {"-"}
       set theSong to theSong as Unicode text
       set theArtist to theArtist as Unicode text
       set AppleScript's text item delimiters to {""} -- Not really needed here, but we're not using any error handling on the shell script, so.
       
       get "http://www.lyricsdir.com/" & theArtist & "-" & theSong & "-lyrics.html"
       do shell script "/usr/bin/curl --user-agent '' " & quoted form of result
       set theLyrics2 to result
       
       set AppleScript's text item delimiters to {"<div id=\"lyrics\">"}
       set theLyrics2 to (last text item of theLyrics2) as Unicode text
       
       set AppleScript's text item delimiters to {"</div>"}
       set theLyrics2 to first text item of theLyrics2
       
       set AppleScript's text item delimiters to {"<br />"}
       set theLyrics2 to text items of theLyrics2
       
       set AppleScript's text item delimiters to {""}
       set theLyrics2 to text 2 thru -1 of (theLyrics2 as Unicode text) -- removes a newline
       
       -- proper way to set the delimiters back (that's why you "saved" them earlier!)
       set AppleScript's text item delimiters to ASTID
       tell window "mainWindow"
           set contents of text view "lyrics" of scroll view "lyrics" to theLyrics2
       end tell
   end if
end clicked

on edittext(someText)
   return do shell script "/usr/bin/python -c \"import sys; print unicode(sys.argv[1], 'utf8').lower().encode('utf8')\" " & quoted form of someText
   -- Remove anything that is not alphanumeric or a space
   return do shell script "echo " & quoted form of someText & " | /usr/bin/ruby -ne 'print $_.delete(\"^a-z\", \"^A-Z\", \"^0-9\", \"^ \")'"
end edittext

on launched theObject
   show window "mainWindow"
end launched

on should quit after last window closed theObject
   return true
end should quit after last window closed

ok i made that way to complicated:P What I am trying to ask is how to you check to see if a check box is checked off or not?
I tried this

set checkstate to selected of button "listen" of window "mainWindow"

but it said access not allowed:/

fixed:D

Care to share with the others?

sure

on idle theObject
set checkstate to contents of button "listen" of window "mainWindow"
	if checkstate is equal to true then--if returned true, check box is checked.
--rest of coding here.
end idle