View unanswered posts | View active topics It is currently Wed May 22, 2013 11:36 pm



Reply to topic  [ 5 posts ] 
 motion detector and itunes script 
Author Message

Joined: Feb 24, 2009
Posts: 156
Location: Calabasas CA
Post motion detector and itunes script
Hi i need some help with my script.

My motion detector is coming from Norm on Wednesday. I would like to embed this script when it detects motion. the problem i am having is to tell the system volume to decrease after the song has played. i realise my code is a bit messy help appreciated.

RT



Code: Select all
tell application "System Preferences"
   activate
   set current pane to pane "com.apple.preference.sound"
   reveal (first anchor of current pane whose name is "output")
end tell

tell application "System Events"
   launch
   tell process "System Preferences" to tell slider 1 of group 1 of tab group 1 of window 1 to set value to 0 --center balance
   tell process "System Preferences" to set value of slider 1 of group 1 of window "Sound" to 7 --maximize volume
end tell
tell application "System Preferences"
   quit
end tell
tell application "iTunes"
   activate
end tell
tell application "iTunes"
   set the current EQ preset to EQ preset "Flat"
end tell
tell application "iTunes"
   set the sound volume to 90
end tell
tell application "iTunes"
   play track named "Just Dance" of playlist "doorbell" with once
end tell
tell application "System Preferences"
   activate
   set current pane to pane "com.apple.preference.sound"
   reveal (first anchor of current pane whose name is "output")
end tell

tell application "System Events"
   launch
   tell process "System Preferences" to tell slider 1 of group 1 of tab group 1 of window 1 to set value to 0 --center balance
   tell process "System Preferences" to set value of slider 1 of group 1 of window "Sound" to 0 --maximize volume
end tell
tell application "System Preferences"
   quit
end tell



Mon Jun 01, 2009 7:51 pm
Profile WWW
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6659
Location: Austin, Texas
Post Re: motion detector and itunes script
artpics wrote:Hi i need some help with my script.

My motion detector is coming from Norm on Wednesday. I would like to embed this script when it detects motion. the problem i am having is to tell the system volume to decrease after the song has played. i realise my code is a bit messy help appreciated.

RT



Code: Select all
tell application "System Preferences"
   activate
   set current pane to pane "com.apple.preference.sound"
   reveal (first anchor of current pane whose name is "output")
end tell

tell application "System Events"
   launch
   tell process "System Preferences" to tell slider 1 of group 1 of tab group 1 of window 1 to set value to 0 --center balance
   tell process "System Preferences" to set value of slider 1 of group 1 of window "Sound" to 7 --maximize volume
end tell
tell application "System Preferences"
   quit
end tell
tell application "iTunes"
   activate
end tell
tell application "iTunes"
   set the current EQ preset to EQ preset "Flat"
end tell
tell application "iTunes"
   set the sound volume to 90
end tell
tell application "iTunes"
   play track named "Just Dance" of playlist "doorbell" with once
end tell
tell application "System Preferences"
   activate
   set current pane to pane "com.apple.preference.sound"
   reveal (first anchor of current pane whose name is "output")
end tell

tell application "System Events"
   launch
   tell process "System Preferences" to tell slider 1 of group 1 of tab group 1 of window 1 to set value to 0 --center balance
   tell process "System Preferences" to set value of slider 1 of group 1 of window "Sound" to 0 --maximize volume
end tell
tell application "System Preferences"
   quit
end tell



Can you explain more precisely what you're trying to do (and your environment)? I think there might be an easier way than trying to script system preferences, but I can't really tell from the script above what that is.... ;)

_________________
Jay (Indigo Support)
Image


Mon Jun 01, 2009 10:18 pm
Profile WWW

Joined: Feb 24, 2009
Posts: 156
Location: Calabasas CA
Post 
thanks Jay.

what i want is when the motion sensor goes off, i want itunes to raise the system volume to 100% and raise the itunes volume to 100%

2. play my sound file once
3. then bring the system sounds back down to say 30%

this is my way of using indigo as my doorbell. the script works but having trouble as i cannot get the sound to stay at 100% while the track plays.

i need a pause in the script until it takes the volume down.

you can test this script by changing the values here with your settings.

tell application "iTunes"
play track named "Just Dance" of playlist "doorbell" with once
end tell


Mon Jun 01, 2009 10:52 pm
Profile WWW

Joined: Mar 09, 2008
Posts: 183
Post 
The command you're looking for is

Code: Select all
Delay N


where N = number of seconds to pause the script.

Also, I don't believe you need separate Tell segments for each iTunes command...Is there some reason they can't all be in the same Tell construct? You can also do one-line Tells, eg rather than

Code: Select all
tell application "iTunes"
   activate
end tell


you can use

Code: Select all
Tell application "iTunes" to activate


Tue Jun 02, 2009 6:22 am
Profile

Joined: Feb 24, 2009
Posts: 156
Location: Calabasas CA
Post 
Thanks Bill it works. :D i will work on refining and adding to my script when i become more experienced with Apple Script.


Tue Jun 02, 2009 12:09 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.   Template designed by STSoftware.