AutoHotkey Community

It is currently May 26th, 2012, 11:48 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: November 7th, 2009, 12:04 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Killing the process is a pretty bad idea with uTorrent and the you may use uTorrent_Exit() which exits uTorrent by simulating File > Exit through WM_COMMAND.
Though the tray icon disappears immediately, the process ( utorrent.exe ) will persist until it notifies the trackers, which would typically take around 10 seconds.

The return value will be Seconds taken if successful or the PID itself if the process was not closed within 20 seconds.

Code:
uTorrent_Exit( ahk_class="µTorrent4823DF041B09" ) {
; by SKAN  www.autohotkey.com/forum/viewtopic.php?t=50732
 hWnd := DllCall( "FindWindow", Str,ahk_class, Int,0 ), TC := A_TickCount
 DllCall( "PostMessage", UInt,hWnd, UInt,0x111, UInt,64, Int,0 ) ; Alt+FX = File > Exit
 Process, WaitClose, utorrent.exe, 20
 Return ErrorLevel ? ErrorLevel : Round( (A_TickCount-TC)/1000,2 )
}


Other PostMessage > wParam values for taming uTorrent

    Tray Menu
  • 60 Hide/Show uTorrent
  • 61 Resume All Torrents
  • 62 Pause All Torrents
  • 63 Exit uTorrent

    File Menu
  • 65 Add Torrent
  • 67 Add Torrent
  • 73 Add Torrent from URL
  • 72 Create New Torrent
  • 64 Exit

    Options Menu
  • 68 Preferences
  • 80 RSS Downloader
  • 82 Speed Guide Dialog
  • 76 Show Toolbar
  • 75 Show Detailed Info
  • 77 Show Status Bar
  • 78 Show Category List
  • 84 Icons on Tabs

    Help Menu
  • 83 uTorrent Help
  • 70 uTorrent Webpage
  • 99 uTorrent Foums
  • 71 Check for Updates
  • 81 Show Statistics
  • 69 About uTorrent


Last edited by SKAN on April 20th, 2011, 8:04 pm, edited 4 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 9th, 2009, 2:54 pm 
Offline

Joined: November 30th, 2008, 1:51 pm
Posts: 73
Do you really need the DllCall()s? I think "DetectHiddenWindows on" and the builtin PostMessage should be enough to do the same job.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 9th, 2009, 3:12 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
jackieku wrote:
"DetectHiddenWindows on" and the builtin PostMessage should be enough to do the same job.


Exactly!. I learnt this alternative from corrupt.

Quote:
Do you really need the DllCall()s?


I prefer functions over a subroutine for the sake of avoiding Global variables,
and I avoid using the following inside functions:
    DetectHiddenWindows
    SetFormat, Integer, Hex
    Gui

Just a matter of preference.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 11th, 2009, 3:02 pm 
thanx, this is useful :wink:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2009, 2:21 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
I discovered more wParam values with brute force.. Titles post updated.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2009, 2:40 pm 
Offline

Joined: June 14th, 2008, 11:46 am
Posts: 5
Thanks SKAN !
This is just what I've been looking for. Now I don't have to recheck my torrents :) .
I tried finding those wParams with WinSpector, but had no luck.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2009, 4:22 pm 
Offline

Joined: September 15th, 2006, 10:25 am
Posts: 567
Great work!!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 4th, 2010, 11:32 am 
Offline

Joined: April 30th, 2010, 8:36 am
Posts: 1
How to automatically resume paused downloads in uTorrent? I have bsnl broadband of 500 combo plan so i usually download in free hours by waking up early at 2:00 a.m. So i started to use the software Autopower-on & shutdown it starts the computer at the specified time and utorrent starts on system startup but when computer is on automatically the uTorrent downloads are either paused/stopped how to resume it automatically when the computer is turned on.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 4th, 2010, 2:22 pm 
Offline

Joined: July 31st, 2008, 10:27 pm
Posts: 336
I've been wanting something like this. Thanks Skan!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 5th, 2010, 4:26 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3330
Location: Simi Valley, CA
bennifera wrote:
how to resume it automatically when the computer is turned on.

The code to tell µTorrent to resume all is
Code:
DetectHiddenWindows, ON
SetTitleMatchMode, Regex
PostMessage, WM_COMMAND := 0x111, UTM_RESUMEALL := 61, 0,, \xb5Torrent

All hail the mighty Skan !

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 17th, 2011, 2:32 am 
Offline

Joined: January 1st, 2011, 10:02 am
Posts: 3
[VxE] wrote:
bennifera wrote:
how to resume it automatically when the computer is turned on.

The code to tell µTorrent to resume all is
Code:
DetectHiddenWindows, ON
SetTitleMatchMode, Regex
PostMessage, WM_COMMAND := 0x111, UTM_RESUMEALL := 61, 0,, \xb5Torrent

All hail the mighty Skan !

so, I'm a long way off from being able to do much more than tweak others scripts, so I'm just trying to get the hang of this, but why do you have:
WM_COMMAND :=
&
UTM_RESUMEALL :=
in there? does this send the variables containing the values?
from my understanding := would just be setting the variable for future calls in AHK, making these un-needed for a one-off script like this. but again, I don't really know what I'm doing.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 17th, 2011, 5:51 am 
Offline

Joined: December 4th, 2006, 10:35 am
Posts: 561
Location: Galil, Israel
right,

it documents what is going on,

this_var := 1, that_var := 2

sets the vars, but also documents what is what...


can take out the this_var := if desired.

_________________
Joyce Jamce


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 18th, 2011, 11:08 am 
Offline

Joined: January 1st, 2011, 10:02 am
Posts: 3
Joy2DWorld wrote:
right,

it documents what is going on,

this_var := 1, that_var := 2

sets the vars, but also documents what is what...


can take out the this_var := if desired.

cool thanks, just wanted to make sure.
any reason I would want to include the variables though? is it just to help read the actual script?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 18th, 2011, 3:16 pm 
Offline

Joined: December 4th, 2006, 10:35 am
Posts: 561
Location: Galil, Israel
exactly.

_________________
Joyce Jamce


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2011, 11:19 pm 
Offline

Joined: February 7th, 2009, 11:28 pm
Posts: 384
hey SKAN, is there an easy way to make this function work in the unicode version of ahk? (64-bit)

_________________
Hardware: 1.8 GHz laptop with 4 GB ram, Windows XP/SP3
Software: Prevx, Privatefirewall, KeyScrambler.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, iDrug, IsNull, Miguel and 56 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group