I have a script that opens up all my daily web comics in Safari for me to read. I don’t have the script on me (unfortunately), but basically it opens up a new Safari window, reads the date, and then goes through and for each web comic I have in the code whether to open it on which days of the week (using a string compare to the date).
To open each page, I call a user function which uses UI scripting to open a new tab in the current window and set the location.
Now normally, this script works just fine - every time I run it myself, I get exactly what I am expecting (one window with many tabs).
I have set it to run right before I get up in the morning using Cron, so that it will be fully loaded when I get to my computer. However, whenever it runs like this, it seems to sort of, but not quite, actually work. Every morning I get a new Safari window, usually with one random tab in it. Some days I get 2 or even 3 tabs in this window. This morning, I got 3 safari windows, each with one or two of my tabs.
I have set the computer never to go to sleep - not the computer, hard drive, or screen. All that happens is the screen saver kicks in. I have set up the Crontab so that my script runs at least an hour after all of the maintenance scripts run (mine starts at 5:30am, IIRC, and I adjusted the times of the other maintenance stuff).
Any ideas why this is working so funkily in the night, and not when I run it?
Oh, and when I set up crontab to run it in the next few minutes while I am watching, it also works fine. :rolleyes:
Killing the screensaver process with that code works, but all it leaves behind is a black screen that still impedes the script progress.
I’ve figured out that just telling “System Events” to keystroke return will do the trick, though.
(actually, right now I’ve got it embedded in a “tell Finder” which is embedded in a “tell System Events” since I copied this code from elsewherre, but I’m not sure if stripping those two extra tell blocks will cause it to stop working or not.)