Howdy all, I read the sticky for noobs (although the description link took me to a 404 page) and am hoping to get a little guidance.
I am VERY new at scripting so bear with me. I would like to write a script that detects if it is iTunes or QuickTime that is currently playing, pause it that app and also set it as “lastPaused”. Later with another script I would like to have it resume whichever app was set as lastPaused.
I got the iTunes portion working:
set iTunesState to ""
property lastPaused : ""
tell application "iTunes" to set iTunesState to (player state as text)
tell application "iTunes" to get player state
if iTunesState is equal to "playing" then
tell application "iTunes" to playpause
set lastPaused to "iTunes"
else if ((iTunesState is equal to "paused") and (lastPaused is equal to "iTunes")) then
tell application "iTunes" to playpause
end if
I am sure there is probably a more elegant/simple way of doing it, but this seems to work. HOWEVER, I can’t make it do the same for QuickTime. Here is what I have for it:
set QuickTimeState to ""
property lastPaused : ""
tell application "QuickTime Player" to set QuickTimeState to (QuickTimeState as text)
if QuickTimeState is equal to "playing" then
tell application "QuickTime Player" to pause v
set lastPaused to "QuickTimePlayer"
else if QuickTimeState is equal to "paused" then
tell application "QuickTime Player" to resume v
set lastPaused to "QuickTimePlayer"
end if
I have no idea why it doesn’t work…does it take different commands? Different definitions? I looked through the built in dictionary in Apple Scriptor but couldn’t find anything that showed me how to get the state for QT.
I’m working on them separately and would like to combine them once it all works for use in a Keyboard Maestro macro that I use for work. Please help! Any ideas are greatly appreciated. And if I broke some forum rule I apologize in advance haha.
-Chris