Need Help with an Applescript / plist This has been a learning experience for me. Everything checks out logically to me in this script/ plist but something isn't correct. Everything runs, but then the script runs every minute which is getting annoying since I'm opening a few programs in the script. If typing code it gets frustrating as it changes the active window.

Note, this is my first applescript and plist excercise so feel free to critique my code. The goal of the script is to be scheduled to run twice daily (2 plists) - in the am change my IM status to available, open some programs and enable an email account. In the evening, change status, disable email.

Since it's re running I figured it was simply the plist, but comparing it to other templates for accomplishing a task which repeats once daily it checks out to me.

&lt;plist version="1.0"&gt;
&lt;dict&gt;
          &lt;key&gt;Label&lt;/key&gt;
          &lt;string&gt;RMWEBENABLE&lt;/string&gt;
          &lt;key&gt;ProgramArguments&lt;/key&gt;
          &lt;array&gt;
                    &lt;string&gt;/disablemail.app/Contents/MacOS/applet&lt;/string&gt;
          &lt;/array&gt;
          &lt;key&gt;StartCalendarInterval&lt;/key&gt;
          &lt;dict&gt;
                    &lt;key&gt;Hour&lt;/key&gt;
                    &lt;integer&gt;8&lt;/integer&gt;
                    &lt;key&gt;Minute&lt;/key&gt;
                    &lt;integer&gt;2&lt;/integer&gt;
          &lt;/dict&gt;
&lt;/dict&gt;
&lt;/plist&gt;


So I'm assuming in my ignorace I have something that's not sucessfully closing an if statement or somethign is just done ineffeciently. Here's the script.

set offTime to 17
set onTime to 9
set dayOfWeek to weekday of (current date)
set theHour to get the (hours of (current date))

if theHour ≥ offTime or dayOfWeek = Saturday or dayOfWeek = Sunday then

  #LEAVE ME ALONE!!!!

          tell application "Mail"
                    set enabled of account "mailbox" to false
          end tell
          tell application "Messages"
                    set status to invisible
          end tell
          tell application "Microsoft Lync"
  quit
          end tell

else if theHour ≥ onTime then

  #I'm available for contact
          tell application "Mail"
                    set enabled of account "mailbox" to true
          end tell

          tell application "Messages"
                    set status to available
          end tell

          tell application "Microsoft Lync"
  activate
          end tell

          tell application "Firefox"
  activate
          end tell

          tell application "Coda 2"
  activate
          end tell

          tell application "Google Chrome"
  activate
          end tell
end if




I guess I could do an absolute value say
else if theHour = 8 and theMinute = 2 then

but I'd prefer the way it is now since My computer may be off when this is scheduled to run, and I believe this will run on wake, or maybe it was a helpful sideeffect of the repeating... I can always change the plist to run on startup as well.
I'm not an Applescript expert, but you might consider simplifying the scripts to remove the timing aspects and use the daemon launchd for scheduling. After all, that's why Apple put it into the OS.

Though you're obviously not afraid of the command line and plist editing, Lingon is an application that provides a simple GUI interface to launchd (for the rest of us).