|
|
Run AppleScript without freezing interface
|
|
|
|
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status:
Offline
|
|
I wrote the following simple script for use as a sleep timer for iTunes:
Code:
tell application "iTunes"
set answer to text returned of (display dialog "Enter the desired delay in minutes" default answer "10")
delay (answer * 60)
playpause
end tell
The only problem is that when I run it through the script menu in iTunes, the iTunes interface freezes for the duration of the delay. Is there any way I can make this run "in the background" or something, so that I can still control iTunes during the countdown?
|
|
|
|
|
|
|
|
|
hayesk
|
|
Try putting all that stuff outside of the tell block.
set answer to text returned of ...
delay (answer * 60)
tell application "iTunes" to playpause
I don't know if this will work, but try it out and let us know.
|
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status:
Offline
|
|
Nope, that didn't do it. Good idea, though.
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status:
Offline
|
|
The wrong answer is a variant on what hayesk said, separate the tell blocks so you are not telling iTunes to delay (a method that actively eats processor cycles, by the way):
Code:
tell application "iTunes"
play
end tell
delay 5
tell application "iTunes"
stop
end tell
The proper way of doing something like this is to use "on idle" methods. There is quite a bit of documentation out there on this once you know that magic phrase, so I will leave you to it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|