Skip navigation

Help Expected end of line, etc. but found end of script.

390 Views 2 Replies Latest reply: Feb 3, 2013 7:06 AM by alex149 RSS
alex149 Level 1 Level 1 (0 points)
Currently Being Moderated
Dec 14, 2012 5:35 PM

here is the sctipt ive tried to write, its not finished so some of the things my seem a bit weird at the moment but here it is as it stands

 

global okflag

set okflag to false

set front_app to (path to frontmost application as Unicode text)

 

-- check if iTunes is running

tell application "System Events"

          if process "iTunes" exists then

                    set okflag to true --iTunes is running

          end if

end tell

 

if okflag is true then

 

          set Timer to ""

  display dialog "Sleep Time (Minutes)" default answer Timer buttons {"Cancel", "OK"} default button 2

          set Timer to text returned of the result

 

          delay Timer * 60

 

          tell application "iTunes"

                    set currentVolume to the sound volume

                    if (player state is playing) then

                              repeat

                                        --Fade down

                                        repeat with i from currentVolume to 0 by -1

                                                  set the sound volume to i

                                                  delay 1

                                        end repeat

                                        pause

                                        --Restore original volume

                                        set the sound volume to currentVolume

                                        exit repeat

                              end repeat

 

                    if okflag is false then

 

                    display dialog "iTunes not playing" buttons {"OK"} default button 1 with icon stop

 

                    end if

                    end

 

it doesnt seem to work after the tell "iTunes part i copied and pasted from another applescript

(the purple text)

MacBook Air, Mac OS X (10.7.1)
  • red_menace Level 6 Level 6 (14,275 points)

    Each if...then and tell statement containing multiple statements needs to be closed with an end if and end tell, respectively.  It looks like something got mangled when pasting in the other script - I'm guessing it should be something like:

     

    global okflag

    set okflag to false

    set front_app to (path to frontmost application as Unicode text)

     

    -- check if iTunes is running

    tell application "System Events"

      if process "iTunes" exists then

        set okflag to true --iTunes is running

      end if

    end tell

     

    if okflag is true then

     

      set Timer to ""

      display dialog "Sleep Time (Minutes)" default answer Timer buttons {"Cancel", "OK"} default button 2

      set Timer to text returned of the result

     

              delay Timer * 60

     

      tell application "iTunes"

        set currentVolume to the sound volume

        if (player state is playing) then repeat

          --Fade down

          repeat with i from currentVolume to 0 by -1

            set the sound volume to i

            delay 1

          end repeat

          pause

          --Restore original volume

          set the sound volume to currentVolume

          exit repeat

        end repeat

      end tell

     

    else

      display dialog "iTunes not playing" buttons {"OK"} default button 1 with icon stop

    end if


Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.