Problem with Synergy and Applescript application

  1. neilio

    I'm not sure if this is off topic or not, but I've been having a problem with an applescript application that I use with Synergy. I use this applescript application in conjunction with a PHP script on my server to upload and update my site with the latest played iTunes tracks.

    You can see an example of the output here:

    http://www.beatnikpad.com/playlist.php

    My problem is this: As far as I can tell, you need to save Applescripts as applications before Synergy will run them on track change. My problem is that my Applescript application sometimes launches but doesn't quit - it just runs in the background not doing anything.

    If I force quit the process, it usually gets "unstuck" and works fine from then on. I'd really like to get this fixed so I could distribute this script publicly.

    Is it possible to have Synergy run compiled Applescripts instead of just applications?

  2. Greg Hurrell

    Yes, it would be possible to do this if I make some changes to the application. As it currently works, it sends an "open" event which should be equivalent to double-clicking stuff in the Finder. Basically, anything which opens and runs as a result of being double-clicked should work fine when triggered by Synergy.

    I don't know what happens with compiled AppleScripts when you double-click them though. I would have thought that they'd run...

    To make these work with Synergy (and even non-compiled ones) I'd have to make changes to the code which treated files with a .scpt extension differently. In those cases, instead of doing the equivalent of a double-click (which would most likely open them in Script Editor which isn't what you want), I could make Synergy read the textual contents of the file, try to compile the text into an AppleScript and then execute it.

    As this is a feature request, I've made an entry for it in the bug tracking and feature requests database. If anyone has any comments to add, please add them there so that all material for this request is kept in one place:

    https://wincent.dev/a/support/bugs/show_bug.cgi?id=303

  3. neilio

    I just added a "quit" command at the end of my applescript and recompiled. It seems to have fixed the issue. I normally don't add "quit" commands into Applescripts as I usually run them as, well, scripts. I'll keep an eye on it and see if it reoccurs. If not, I'll write some basic documentation and package this up and post it somewhere...

  4. Greg Hurrell

    Excellent. I am sure other people will be interested in it!

  5. neilio

    I've found the issue. When iTunes is quit Synergy runs the Track Changes items. Because it's an applescript application that requires iTunes it re-launches iTunes. My guess is this is a bug - there's no reason why the Track Changes items should be run when iTunes is quit or started - only when there's a track change.

    Can this be changed for the next release?

  6. Greg Hurrell

    I'm not sure. You see, track change items are run whenever Synergy receives a notification from iTunes that things have changed. So in the case of quitting iTunes sends a notification. Some scripts may actually depend on this behaviour (for example, to update state to "not playing" or "not running"). Can you add a line to your script to check that iTunes is running before doing anything? That way it handles that specific case but still leaves the door open for people whose scripts need to respond to a quit event.

    I could change this behaviour in a future release (ignore notifications from iTunes when it quits) but I am not sure if it's the correct thing to do. Anyone else have an opinion on this one?

  7. peeweejd

    I added a little blurb to my applescript that checks to see if iTunes is running before it gets any information. It seems to work fine now.

    Code:if process "iTunes" exists then

    Check out this thread for my applescript: https://wincent.dev/a/support/forums/showflat.php?Cat=0&Number=845&an=0&page=0

Reply

This topic is now closed.