views:

174

answers:

2

I'm building an Applescript that will scan my network every X minutes, checking for my house's Xbox360 or PS3 and enabling my Transmission BitTorrent client Speed-Limit Mode when either console is online.

Currently I can only Pause all transfers or resume all transfers using applescript, as there are separate key-commands for start/stop transfer. I want it to go into speed-limit mode though, not stop completely.

My issue is that the Speed-Limit (Turtle) mode is the same key to turn it on/off. If anyone touches the speed-limit manually, it will be out of sync and will actually turn speed-limit off when the consoles come online. Also if one console comes online, the speed-limit will come on, but then if the other console comes on, the limit will be turned off.

The menu item becomes 'checked' when the speed-limit is active, but I do not know how to test for this. There was nothing in the applescript dictionary for the transmission app.

How can I determine whether a menu item is 'checked'(It even shows an actual check-mark) in Applescript?

[Edit:] I'm currently trying to figure out how to turn the Speed-Limit on via RPC, rather than trying to script it using the GUI or keycommands, since the developers don't provide any applescript access. http://trac.transmissionbt.com/browser/trunk/doc/rpc-spec.txt

A: 

What information you are able to divine from any given application via AppleScript is entirely up to said application's developer. If Transmission doesn't define any way for you to determine this state, then you're not going to be able to do so with any degree of reliability.

It would make far more sense to invest $40-$50 in a router with quality of service controls that would allow you to prioritize your network traffic by port or by device.

Azeem.Butt
Unfortunately we have a fairly new router (D-Link DIR-615 802.11n/g) and the QoS is not working well enough. There's no real configuration options either, just whether to turn it on or off, and your uplink speed.
Aaron
Unfortunately, there really isn't any third option here unless you plan on leaving all of your windows in one place forever, in which case you might be able to hack something together through GUI scripting.http://www.macosxautomation.com/applescript/uiscripting/index.htmlOtherwise, what you can and can't do with AppleScript is beyond your control. File a feature request with Transmission's developer.
Azeem.Butt
My current revised plan of action is to use RPC to control Transmission from Applescript, but I'm currently getting a 'Transport Error' that I need to figure out.I don't object to writing this in python either, it just seemed simpler at first glance to write using Applescript. Plus, I just wanted to try AScript out a little more in-depth than I have before.
Aaron
That still places you at the mercy of the application's developer. The amount of time you will spend on this is almost certainly not worth the cost of a WRT54GL flashed with Tomato, but good luck.
Azeem.Butt
Yes, I'm "still at the dev's mercy", but the difference is that RPC is fully supported and recommended to be used by the devs, they even created a whole API documentation for it.http://trac.transmissionbt.com/browser/trunk/doc/rpc-spec.txt<br /><br />The amount of time I spend on this problem is all part of the learning experience, which is mainly what this is about. I could have easily stuck with my first version that just did START/STOP, but it's always about improving your code and refactoring, isn't it?<br />Thanks for your help.
Aaron
+2  A: 

I had the exact same issue, and finally figured out how to check if Transmission's Speed Limit menu item is checked (and you could easily modify this to check for menu items in other applications). This has been dead for almost a year now, but hopefully this helps.

tell application "Transmission" to activate

tell application "System Events"
    tell process "Transmission"
        set speedLimitCurrentlyOn to (value of attribute "AXMenuItemMarkChar" of menu item "Speed Limit" of menu "Transfers" of menu bar 1 as string) ≠ ""

        display dialog "Speed Limit On: " & speedLimitCurrentlyOn
    end tell
end tell

PS: I adapted this from the AppleScript here: http://mac.softpedia.com/progDownload/Transmission-Auto-Speed-Limit-Download-60275.html

Dov
Thanks! I'll try it out when I get the chance.
Aaron
How did that end up working out for you? I should also mention it uses GUI scripting, so you may have to enable that. See here: http://www.macosxautomation.com/applescript/uiscripting/index.html
Dov