Hey, is there a way to hide a custom slider widget if an associated app is not running? Basically, I have a custom slider that controls the Music app volume control (which is separate from the system volume in AirPlay). That much works. But I'd like the slider to auto-hide if the Music app is not running. A few people have had success with techniques for regular buttons, but I can't get them to work for the custom slider.
What seems to be happening is that if the Music app isn't running, then the slider is sent a blank value (return ""), which gets interpreted as a zero and the slider remains visible, set to zero.
I've tried "return null", "return missing value", and "return false" in the scripts, but the same thing happens.
Any ideas how to hide a custom slider widget for an app that isn't running?
My widget-specific AppleScript is:
if application "Music" is running then tell application "Music" set itunesvolume to sound volume end tell set currentvolume to itunesvolume / 100 return currentvolume else return "" end if
My predefined action (AppleScript async) is:
on bttWidgetSliderMoved(sliderValue) if application "Music" is running then tell application "Music" try set the sound volume to sliderValue * 100 end try end tell else return "" end if end bttWidgetSliderMoved