Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > AppleScript > Salling Clicker > Proximity/iTunes problems

AppleScript > Salling Clicker > Proximity/iTunes problems
Thread Tools
Fresh-Faced Recruit
Join Date: Jul 2002
Location: Karlshamn, Sweden
Status: Offline
Reply With Quote
Dec 2, 2003, 03:51 PM
 
Making a Proximity script that stores whether iTunes was playing or not when you leave the computer, and uses that state when you return. Here's the relevant code:

Code:
on entered_proximity() tell application "System Events" set the process_flag to (exists process "iTunes") end tell if the process_flag then set wasiTunesPlaying to ¬ (do shell script "defaults read nu.mine.alastor.ClickerScripts ClickiTunesWasPlaying") = "1" if wasiTunesPlaying = true then tell application "iTunes" to play end if end if end entered_proximity on left_proximity() tell application "System Events" set the process_flag to (exists process "iTunes") end tell if the process_flag then tell application "iTunes" do shell script ¬ "defaults write nu.mine.alastor.ClickerScripts ClickiTunesWasPlaying -boolean " & ¬ (((player state as string) = "playing") as string) end tell tell application "iTunes" to pause end if end left_proximity
nu.mine.alastor.ClickerScripts ClickiTunesWasPlaying is always set to 0 when run through the left_proximity! The code works flawlessly when run in Script Editor.

I can't find an error in the code. It seems as if iTunes is paused by something else before my left_proximity code is executed. But I've made sure -- there are NO events assigned to "leaving the computer", nor is any other iTunes proximity script active!

I just can't figure it out! Can anyone help me?


ps. If you want to try the code, the above works just nicely, if you just copy it into a new Proximity Script and replace the default contents with it
Move .Sig... For Great Justice!
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:29 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2