Hello , I’m new in Apple script , I think it’s very powerfull but I can’t understand it very much . I’m not a programmer eather , but I need a simple code .
My intention it’s to make a script that open a location every X second but the code that I wrote it take cpu to 100% and it can’t quit the script .
I need iTunes open a location to see the pod cast’s Top 20 chart every X seconds , but with my BAD and Simple code I’ve this insue :
Can’t quit applescript
Some time iTunesMusic store tell me error so I’ve to manualy click the pront to let it back to work
iTunes.app come in front every call open location
If I’m running the AS in iTunes Script Folder iTunes don’t respond any more
This is my bad code , can you help me please ?
ignoring application responses
tell application "iTunes"
run
repeat
open location "itms://phobos.apple.com/WebObjects/MZStore.woa/wa/viewGenre?id=26"
delay 60
end repeat
end tell
end ignoring
Nearly trashed my itunes with this script.
you either have to watch the frequency with which it scans ITMS or it may have caused my router to have indigestion!
Either way be careful!!!
my version is:
ignoring application responses
repeat
tell application "iTunes"
run
activate
open location "itms://phobos.apple.com/WebObjects/MZStore.woa/wa/viewGenre?id=26"
--give itunes time to download the page
delay 40
quit
end tell
-- delay before script runs again
delay 20
end repeat
end ignoring
Don’t understand your other problems with itunes coming to the front etc? How else can you see what you want to see?
How frequently do you want to run the script. There are shareware apps such as cronnix which can schedule a script to run at certain times on selected days. It is really just a user friendly frontend to the cron function in unix.
This is the only way to stop and start the script itself otherwise it must run all the time. If you remove the “Quit” line from the script then ITunes will be open all the time. If you remove the “activate” then it will not come to the front, but then how can you see the itunes info that you talked about?
I can show you a cronnix sample command to run an applescript every weekday at a fixed time if you think that would help.
riverman
is an endless loop and will continue running until you stop it. If you use the idle handler, you can set a time to check periodically and test that with an if statement. If the time meets your criteria then you perform your actions.
on idle
tell application "Finder"
set theTime to the time of (current date)
set testDate to (current date) - theTime -- the current day at 12:00 AM
end tell
if time of (current date) is greater than or equal to 21600 then -- 6:00 AM current day
tell application "iTunes"
open location "itms://phobos.apple.com/WebObjects/MZStore.woa/wa/viewGenre?id=26"
end tell
end if
end idle
I haven’t tried the above code so there may be errors. Save this as a stay open application (button at the bottom of the save as dialog box).
PreTech
Model: dual 1.8 G5
AppleScript: 2.1 (80)
Browser: Safari 412.5
Operating System: Mac OS X (10.4)
on idle
tell application "Finder"
set theTime to the time of (current date)
set testDate to (current date) - theTime -- the current day at 12:00 AM
end tell
if time of (current date) is greater than or equal to 21600 then -- 6:00 AM current day
tell application "iTunes"
open location "itms://phobos.apple.com/WebObjects/MZStore.woa/wa/viewGenre?id=26"
end tell
end if
delay 20
end idle
You then save this as a stay open application. Then you double click it to start it. An icon will show up in your dock and you can quit it like any other program.
One more thing . I need to quit iTunes every X minute .
Some time itms give me back some error message , the simplest way to let the script work in automatic it’s to quit iTunes every 5 / 6 minute . There is any way to do this ?
property elapsedTime : 600 -- sets the variable elapsedTime to 600 seconds.
on idle
tell application "Finder"
set theTime to the time of (current date)
set testDate to (current date) - theTime -- the current day at 12:00 AM
end tell
if time of (current date) is greater than or equal to 21600 then -- 6:00 AM current day
tell application "iTunes"
open location "itms://phobos.apple.com/WebObjects/MZStore.woa/wa/viewGenre?id=26"
end tell
end if
delay 20
if the (time of (current date)) is greater than or equal to (theTime + elapsedTime) then
tell application "iTunes"
quit
end tell
end if
end idle
property timeInterval : 60 -- in seconds
property theURL : "itms://phobos.apple.com/WebObjects/MZStore.woa/wa/viewGenre?id=26"
property downloadTime : 40 -- in seconds
on run
set justDone to false
end run
on idle
if justDone then
quit application "iTunes"
set justDone to false
else if time of (current date) is greater than or equal to 21600 then -- 6:00 AM
tell application "iTunes" to open location theURL
set justDone to true
return downloadTime
end if
return timeInterval
end idle
So are timeInterval and downloadTime special operators in AS? I ask this because I don’t understand how they function without more code involving their use. And if they are special operators where can I find info about other special operators?
I hate to keep bothering you, but I’ve got to ask again. I understand for the most part the
property timeInterval : 60
but what I’m not understanding is how the script knows this number is in seconds as opposed to milimeters or any other units and that it essentially needs to count 60 seconds (or however long). How does it know to wait for “x” many seconds?