I wrote and ran a background script last night for the first time following some of the threads in here but have a couple of questions. I can execute the script and it runs fine but it won't trigger by itself. The script I wrote runs from 10pm to 11pm. My last program ends at 9:58pm. I associated the background script with vixen but when it's time to run the script it doesn't automatically start (and there is no other sequence on at that time). Is there something else that I must do?
The reason I ask is lately I've been rebooting my pc daily to make sure there aren't any stability problems. I have Vixen autorun when Windows comes up but if the script doesn't automatically execute what should I do? In that case I would have to manually execute the script then set auto reboot to off.
Just to be clear when I execute the script the lights do what I want so the script is working, I just want it to automatically run (in the background) when Vixen starts.
I hope this makes sense but I'm new to background scripts and how they are triggered. Here's the script I was using last night:
void Start() {
// The compiler will ignore anything after two forward slashes, like these comments.
// I've placed comments in the code to try to explain what I'm doing.
// Since each thing we're controlling is made up of multiple channels,
// we're going to build collections of channels to control, one for each
// entity.
Off(All);
ChannelCollection mediumTreeWhite;
ChannelCollection mediumTreeBlue;
ChannelCollection presentBoxes;
mediumTreeWhite = Channels(Channel_1, Channel_3, Channel_5, Channel_7, Channel_9, Channel_11, Channel_13, Channel_15);
mediumTreeBlue = Channels(Channel_2, Channel_4, Channel_6, Channel_8, Channel_10, Channel_12, Channel_14, Channel_16);
presentBoxes = Channels(Channel_17, Channel_18);
DateTime now = DateTime.Now; //get the current time
//The DateTime constructor goes (YYYY, MM, DD, HH, MM, SS)
DateTime start = new DateTime(now.Year, now.Month, now.Day, 22, 00, 00);
DateTime end = new DateTime(now.Year, now.Month, now.Day, 23, 00, 00);
//We only want the channels to turn on while the current time is
//between 10pm and 11 pm
while (now.CompareTo(start) >= 0 && now.CompareTo(end) <= 0)
{
// These are static, they will not change, so we will turn them on and
// leave them.
On(presentBoxes, At(50)); // At 50%
// This will repeat forever until it's stopped by the application.
// Ramp from 0-100% over the span of one second and wait for it to complete.
Ramp(mediumTreeWhite, 0, 100, Over(1).Second, Wait);
// Have the channels on at full intesity for 5 seconds and wait for it to complete.
On(mediumTreeWhite, For(5).Seconds, Wait);
// Fade from 100-0% over the span of one second and wait for it to complete.
Ramp(mediumTreeWhite, 100, 0, Over(1).Second, Wait);
Ramp(mediumTreeBlue, 0, 100, Over(1).Second, Wait);
On(mediumTreeBlue, For(5).Seconds, Wait);
Ramp(mediumTreeBlue, 100, 0, Over(1).Second, Wait);
now = DateTime.Now; //update the current time
}
Off(All);
}
Have you enabled the background script and set the delay time? It's under: Tools - Preferences - Background Items. Just a thought, I hope it helps! -Paul
I love it when there is an easy answer. 😀
Thanks Paul, that did the trick!
No problem. Glad I could help!
