I dont know if I should post this here or under my previous post…but here it is. This script will start 1 of 2 apps that I made, based on the month and time. The script works great. However, it keeps looping the activation of the program at the end. To make matters more weird, it does not have this problem if I put normal app, like ichat and itunes in it. Otherwise, it just keeps telling the app to activate when it is done doing its thing. here are my questions:
- Do you know why this would loop? Is it something in the way I saved my 2 apps?
- Is there a way to shut this script off immediatly once it tells the program to activate?
set theMonth to month of (current date) as text
if theMonth is "January" then
set sunRise to timeAsSeconds given hours:7, minutes:20
set sunSet to timeAsSeconds given hours:17, minutes:35
end if
if theMonth is "Febuary" then
set sunRise to timeAsSeconds given hours:7, minutes:15
set sunSet to timeAsSeconds given hours:18, minutes:5
end if
if theMonth is "March" then
set sunRise to timeAsSeconds given hours:6, minutes:40
set sunSet to timeAsSeconds given hours:18, minutes:35
end if
if theMonth is "April" then
set sunRise to timeAsSeconds given hours:8, minutes:0
set sunSet to timeAsSeconds given hours:19, minutes:30
end if
if theMonth is "May" then
set sunRise to timeAsSeconds given hours:6, minutes:25
set sunSet to timeAsSeconds given hours:20, minutes:30
end if
if theMonth is "June" then
set sunRise to timeAsSeconds given hours:6, minutes:15
set sunSet to timeAsSeconds given hours:12, minutes:0
end if
if theMonth is "July" then
set sunRise to timeAsSeconds given hours:6, minutes:20
set sunSet to timeAsSeconds given hours:20, minutes:45
end if
if theMonth is "August" then
set sunRise to timeAsSeconds given hours:6, minutes:45
set sunSet to timeAsSeconds given hours:20, minutes:20
end if
if theMonth is "September" then
set sunRise to timeAsSeconds given hours:7, minutes:15
set sunSet to timeAsSeconds given hours:19, minutes:40
end if
if theMonth is "October" then
set sunRise to timeAsSeconds given hours:7, minutes:15
set sunSet to timeAsSeconds given hours:18, minutes:45
end if
if theMonth is "November" then
set sunRise to timeAsSeconds given hours:7, minutes:10
set sunSet to timeAsSeconds given hours:17, minutes:20
end if
if theMonth is "December" then
set sunRise to timeAsSeconds given hours:7, minutes:35
set sunSet to timeAsSeconds given hours:17, minutes:15
end if
-----------------------------------------------
get time of (current date)
if (result > sunRise) and (result < sunSet) then
activate application "Daylight scc"
else
activate application "nightime scc"
end if
on timeAsSeconds given hours:myHours, minutes:myMinutes
return (myHours * hours + myMinutes * minutes)
end timeAsSeconds