Updated 2013-02-17: “Much Improved”
A few months ago I started using Deluge as my torrent client instead of µTorrent. Whilst overall I feel Deluge is considerably better, one issue I’ve had is that it doesn’t prevent my computer from sleeping, which is an a bit of an issue if the computer is left unattended download something. This script disables sleep when Deluge is active using AutoIt, and resets sleep to the previous value once downloads have finished. For this to work Deluge needs to be in classic mode with show session speed in title bar activated, both of these settings are found under preferences/interface. Also, a word of warning, this may not work on versions of Windows earlier than 8, though you’re welcome to try it, also note its guaranteed not to work on Windows XP and earlier. You can run this without AutoIt just download the executable version.
Something else to keep in mind is that this works using a relatively simple macro which by necessity flashes screens open, changes options and presses buttons. If this kind of behaviour concerns you, you may wish to avoid using the script.
Downloads
Executable
Script (Requires AutoIt 3 to run)
(You may need to right click and select “save as” or whatever variant is in your menu.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | ; A script to toggle sleep off while deluge is downloading files and turn it back on once its finished and vice versa. ; Created by Furgelnod of furgelnod.com Global $osValue = "" Global $sValue = "" $delugeexe = StringTrimLeft( StringTrimRight( RegRead( "HKEY_CLASSES_ROOT\Deluge\shell\open\command", "" ), 6 ), 1 ) AutoItSetOption ( "WinTitleMatchMode", 2 ) AutoItSetOption ( "TrayAutoPause", 0 ) If Not FileExists ( $delugeexe ) Then MsgBox( 16, "", "Deluge is not installed" ) Exit EndIf If Not ProcessExists ( "deluge.exe" ) Then run ( $delugeexe ) EndIf ProcessWait ( "deluge.exe" ) While ProcessExists( "deluge.exe" ) If WinExists ( " - Deluge" ) and WinExists( "D:0.0" ) and $sValue <> $osValue Then $sValue = $osValue Call ( "_toggleSleep" ) EndIf If WinExists ( " - Deluge" ) and Not WinExists( "D:0.0" ) and $sValue <> "Never" Then $sValue = "Never" Call ("_toggleSleep") EndIf If Not WinExists( " - Deluge" ) and ProcessExists( "deluge.exe" ) Then sleep ( 10000 ) If ProcessExists ( "deluge.exe" ) Then run ( $delugeexe ) WinActivate ( " - Deluge" ) WinWaitActive ( " - Deluge" ) WinClose ( " - Deluge" ) EndIf EndIf sleep( 10000 ) WEnd If $osValue = "" Then Exit EndIf If $sValue = $osValue Then Exit EndIf $sValue = $osValue Call ( "_toggleSleep" ) Exit Func _toggleSleep() run ( "control.exe /name Microsoft.PowerOptions /page pagePlanSettings" ) WinActivate ( "Edit Plan Settings" ) WinWaitActive ( "Edit Plan Settings" ) If $osValue = "" Then $osValue = ControlGetText ( "Edit Plan Settings", "", "[CLASS:ComboBox; INSTANCE:4]" ) EndIf ControlCommand ( "Edit Plan Settings", "", "[CLASS:ComboBox; INSTANCE:4]", "SelectString", $sValue ) ControlClick ( "Edit Plan Settings", "Save changes", "[CLASS:Button; INSTANCE:1;]" ) WinWaitActive ( "Power Options" ) WinClose ( "Power Options" ) EndFunc |








