Created
January 23, 2014 00:18
-
-
Save mlgill/8570372 to your computer and use it in GitHub Desktop.
AppleScript to control throttling of BitTorrent Sync on Mac, optionally using Keyboard Maestro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --Applescript to (un)throtle BitTorrent Sync | |
| --Requires AppleScript Editor to have Accessibility permissions in Mavericks | |
| --Michelle L. Gill, 2014/01/22 | |
| --limitBTsync is set to 1 to limit bandwidth or 0 for unlimited bandwidth | |
| --this assumes the appropriate text boxes are already populated with | |
| --the values for limited bandwidth | |
| tell application "Keyboard Maestro Engine" | |
| set limitBTsync to the value of (make variable with properties {name:"limitBTsync"}) | |
| end tell | |
| --alternatively the variable can be set directly like this | |
| --set limitBTsync to 1 | |
| tell application "System Events" | |
| --get the name of the frontmost application | |
| set frontApp to name of item 1 of (every process whose frontmost is true) | |
| try | |
| --temporarily put BitTorrent Sync in front for UI scripting | |
| tell process "BitTorrent Sync" to set frontmost to true | |
| --get the list of buttons at the top and click the Preferences one | |
| set buttonList to every button of toolbar 1 of window 1 of process "BitTorrent Sync" | |
| repeat with b in buttonList | |
| if title of b is "Preferences" then | |
| set prefButton to b | |
| end if | |
| end repeat | |
| click prefButton | |
| --find the checkboxes for limiting upload and download | |
| set checkboxList to every checkbox of window 1 of process "BitTorrent Sync" | |
| repeat with c in checkboxList | |
| if title of c contains "limit" then | |
| if value of c is not equal to limitBTsync then | |
| click c | |
| end if | |
| end if | |
| end repeat | |
| end try | |
| --put the original application back in front | |
| tell process frontApp to set frontmost to true | |
| end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment