 |
 |
Apple Script and a 3 minute timer?
|
 |
|
 |
|
Mac Elite
Join Date: May 2001
Location: Up north
Status:
Offline
|
|
This is a startup script someone asked me to make for them... (What it is supposed to do)
--------
open iTunes
play something in iTunes
open Limewire, and hide it
open Mail
after 3 minutes bring Limewire to the front
lauch Seti
---------
I can do everyting on here, except the 3 having the thing bring Limewire to the front after 3 minutes. Is this even possible, do I perhaps have to program a simple program that waits for 3 minutes and then brings Limewire to the front. I would really rather have all of this in Applescript, instead of programming something in C++.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: May 1999
Location: San Jose, CA
Status:
Offline
|
|
You can do it a couple of ways.
The simplest is use delay:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
-- do something
delay <font color = blue>180</font> -- pause for <font color = blue>3</font> minutes
-- do something else
</font>[/code]
The alternative is to use a code timer:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
set theTime to current date
-- do something
repeat until current date >= (theTime + <font color = blue>180</font>)
end repeat
-- do something else
</font>[/code]
In the latter form, the script sits in a loop until 'current date' is greater than/equal to (the saved date + 180 seconds)
|
|
Gods don't kill people - people with Gods kill people.
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: May 2001
Location: Up north
Status:
Offline
|
|
Wow, that is perfect, exactly what I was looking for!!!
Thanks... 
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Aug 1999
Location: Calgary, Alberta, Canada
Status:
Offline
|
|
Although the repeat will work, it will gobble up a lot more processing power than the delay command. Unless you need to do something during the "pause", the delay command is more processor friendly.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 2000
Status:
Offline
|
|
This is slightly off topic.. but if you want to show AppleScript code, you can use this script, it requires the clipboard to html osax from osaxen.com... I also have a version that gives you pure html rather than just UBB code, to use this script, save it as an applet. Then whenever you want to post a script, copy the script, double click on the applet, wait till it beeps, then you have UBB code:
on run
set theConvert to convert the clipboard to html
set the clipboard to ((my replaceSubstrings({"<", ">", " ", "¬", "&", tab}, {"[", "]", " ", "¬", "&", " "}, theConvert)) as string)
delay 0.4
beep
end run
on replaceSubstrings(searchString, replaceString, thestring)
repeat with i from 1 to length of searchString
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to (item i of searchString)
set tempList to text items of thestring
set AppleScript's text item delimiters to (item i of replaceString)
set thestring to tempList as string
set AppleScript's text item delimiters to oldDelim
end repeat
return thestring
end replaceSubstrings
BTW, the above formatting was all generated by the script above.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: May 1999
Location: San Jose, CA
Status:
Offline
|
|
Originally posted by King Chung Huang:
<STRONG>Although the repeat will work, it will gobble up a lot more processing power than the delay command. Unless you need to do something during the "pause", the delay command is more processor friendly.</STRONG>
You're right that the repeat loop is more processor intensive since it's continually calling current date to check its value.
However, delay wasn't added to the standard dictionary until AppleScript 1.4 (I think?). Earlier versions will fail to compile delay, necessitating the use of a third-party osax or the repeat loop.
|
|
Gods don't kill people - people with Gods kill people.
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: May 1999
Location: San Jose, CA
Status:
Offline
|
|
Originally posted by King Chung Huang:
<STRONG>Although the repeat will work, it will gobble up a lot more processing power than the delay command. Unless you need to do something during the "pause", the delay command is more processor friendly.</STRONG>
You're right that the repeat loop is more processor intensive since it's continually calling current date to check its value.
However, delay wasn't added to the standard dictionary until AppleScript 1.4 (I think?). Earlier versions will fail to compile delay, necessitating the use of a third-party osax or the repeat loop.
|
|
Gods don't kill people - people with Gods kill people.
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: May 2001
Location: Up north
Status:
Offline
|
|
Thanks for posting that script, I am copying and compiling it right now.
And yes, I think I will use the delay, because this guy I am making the script for is having something being run in the background till it is ready, which is after 3 minutes, so he needs the extra cycles. He has a new enough computer that he will have the updated applescript on it.
I am sure there will be a time when I will use the repeat loop as well, so thanks for that.
Oh and I need to minimize an iTunes window. Does anyone have a clip of a script that can do that?
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 2000
Status:
Offline
|
|
Originally posted by 11011001:
<STRONG>Oh and I need to minimize an iTunes window. Does anyone have a clip of a script that can do that?</STRONG>
Either of the three depending on what OS you are in...
tell application "iTunes"
set collapsed of window 1 to true
end tell
tell application "iTunes"
set zoomed of window 1 to true
end tell
tell application "iTunes"
set minimized of window 1 to true
end tell
[ 11-17-2001: Message edited by: Synotic ]
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: May 2001
Location: Up north
Status:
Offline
|
|
Excellent, that is what I thought it was... or close too, I was just doing something wrong.
Well now I can get the thing to work without giving any errors, but the trouble is iTunes won't respond to the command, I suspect it can't...
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
If you're talking about the minimizing script, it works fine for me.
tell application "iTunes"
set collapsed of window "iTunes" to true
set collapsed of window "Equalizer" to true
end tell
The windows kindly zoom down into the Dock, and all is right in the world.
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
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
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|