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.
<plist version="1.0"> <dict> <key>Label</key> <string>RMWEBENABLE</string> <key>ProgramArguments</key> <array> <string>/disablemail.app/Contents/MacOS/applet</string> </array> <key>StartCalendarInterval</key> <dict> <key>Hour</key> <integer>8</integer> <key>Minute</key> <integer>2</integer> </dict> </dict> </plist>
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.