Transmission Bandwidth Settings Script/Function

I needed something to change the settings in Transmission from a cron but it isn’t scriptable (beyond open ,quit activate), even tried working out how to make it scriptable with no luck, but i wrote this for the 0.6 beta which seems to be working fine. So i came up with this UI script to change settings.

was written for http://www.chucker.rasdi.net/opensource/transmission/Transmission-0.6-svn-r232-2006-04-15.dmg

THIS WILL ONLY WORK ON VERSIONS OF TRANSMISSION THAT HAVE A DOWNLOAD LIMIT AND UPLOAD LIMIT SETTINGS.

also checks whether UI scripting is enabled and helps you turn it on if not.


setTransmission(3, true, 3, true, false)


(*  SetTransmission Function Parameters
#1 Upload Rate  (number)
#2 Upload Rate Check (true/false)
#3 Download Rate (number)
#4 Download Rate Check (true/false)
#5 Hide Transmission when settings done. (true/false)  *)

on setTransmission(UP_RATE, UpCheck, DL_RATE, DownCheck, HideAfter)
	-- Dont touch these 
	set LDR to "Limit Download Rate:"
	set LUR to "Limit Upload Rate:"
	
	tell application "Transmission" to activate
	tell application "System Events"
		if UI elements enabled then
			tell application process "Transmission"
				keystroke "," using command down
				delay 0.2
				tell window 1
					tell button "Network" of tool bar 1 to click
					
					--Make sure upload rate checkbox is on we can change the value
					tell checkbox LUR
						if value is 0 then click
					end tell
					
					--change upload rate
					set value of text field 2 to "" & UP_RATE & "" --trick it into thinking its a string
					
					--we need to turn on then off here so transmission recognises the change	
					-- and vise versa
					tell checkbox LUR
						if UpCheck then
							if value is 1 then click
							if value is 0 then click
						else
							if value is 0 then click
							if value is 1 then click
						end if
					end tell
					
					--Make sure download rate checkbox is on we can change the value
					tell checkbox LDR
						if value is 0 then click
					end tell
					
					-- Set the Download Rate
					set value of text field 1 to "" & DL_RATE & "" --trick it into thinking its a string
					
					--we need to turn on then off here so transmission recognises the change	
					-- and vise versa
					tell checkbox LDR
						if DownCheck then
							if value is 1 then click
							if value is 0 then click
						else
							if value is 0 then click
							if value is 1 then click
						end if
					end tell
					
					--give it half a second
					delay 0.5
					
					-- Close the preferences window
					keystroke "w" using command down
				end tell
				
				--Hide After
				if HideAfter then keystroke "h" using command down
			end tell
		else
			display dialog "You Need To Turn on GUI Scripting,
Click Ok to Open AppleScript Utility, so you can turn it on"
			tell application "AppleScript Utility" to activate
			
		end if
	end tell
end setTransmission

Hi Kim, or how might been reading this, I’ve been using this function in some of my apps to control Transmission, and it works pretty nice, I’ve been trying to script the “Transfer” toolbar item and then access the “Adding” tab in the tabview that are in that area, but I can’t get any result when trying to set “Default download lication”, keep incomplete file in, watch for torrents in" but Im not having any luck in doing so, can somebody help me on the way in this…

Mkh

OK, I feel SO stupid right now, never though of just using Transmissions plist to do things, somebody plz plz kick me :///