Forum closed
This forum was closed and turned into an archive effective April 21, 2018. It is no longer possible to create new topics or reply to existing topics.

Thanks everyone for all the great questions and contributions over the years.

Please use the Contact form to get in touch.

Remote Buddy Forum

Overview 

AuthorThread
User

26.03.2015 21:50:31
[Resolved] AppleScript deactivate sticky behavior
View

This posting is older than 6 months and can contain outdated information.
Hi,

I've read all I could about this subject but couldn't find out a working solution to my problem.

I wrote an AppleScript application which sends various commands to VLC and for which I'd like to have a custom behavior activated. I've written and installed my behavior and the script activates it and makes it sticky just after VLC has been launched (if I don't make it sticky then RB switches back to VLC) :

tell application "Remote Buddy" to behaviourcore accessor "setActiveBehaviour" identifier "com.me.scriptedbehaviours.myscriptapplication" useActivationEventCode "activated" with stickyValue

Everything's okay. Now the problem with this is that I have to manually deactivate the behavior once the script application has quit. I'd like RB to switch back to default behavior or whatever is running once the script has quit. I tried adding this to the quit handler of my app (as I understand it it should still detect my script running but clear the stickyValue) :

tell application "Remote Buddy" to behaviourcore accessor "triggerAutoRecognition"

also tried to activate default behavior :

tell application "Remote Buddy" to behaviourcore accessor "setActiveBehaviour" identifier "com.iospirit.remotebuddy.defaults" useActivationEventCode "activated"

Both result in my script and RB hanging until I force quit the script. I still didn't figure out a way to "unstick" the behavior or return back to default (would be nice to have an example for this in the dictionary).

Thanks

Last edited: 26.03.2015 22:12:08 

These entries from the FAQ may be relevant to this topic:

Configuration
Hardware - Apple® Remote
User

26.03.2015 22:08:12
Re: AppleScript deactivate sticky behavior
View

This posting is older than 6 months and can contain outdated information.
Well, I finally got it shortly after.

The problem was I had a remote button which would tell the script application to quit. Due to the nature of AppleScript, this makes RB stuck until the quit handler of the application has successfully ended. So once pressed the quit handler would run and try to tell RB to unstick the behavior, and once again this would make the script stuck until RB has successfully changed behavior. So both the script and RB were waiting endlessly for each other.

I overcame this by modifying my behavior action in construction kit so that it runs the script that tells the script application to quit and then deactivates behavior. Now the behavior is not reset by the script application's quit handler but by the RB action itself.

Hope that'll help somebody.

Edit : Oh by the way, thanks a lot to IOspirit for this wonderful software, RB + AppleScript = endless possibilities. I love it !

Last edited: 26.03.2015 22:20:29