AutoHotkey Community

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

All times are UTC [ DST ]




Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: November 5th, 2009, 7:47 pm 
Offline

Joined: September 10th, 2009, 5:54 pm
Posts: 203
Is there a way to check if a program is downloading? and if not then do something?
uTorrent for example


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 6th, 2009, 2:18 am 
Offline

Joined: January 22nd, 2009, 3:43 pm
Posts: 84
In utorrent: /Options/preferences/Directories/Move .torrents for finished jobs to:C:\downloadcomplete\

This will only move the .torrent descriptor file after a completed download, not the whole file

Code:
torrentfile = mytorrent
IfNotExist, C:\downloadcomplete\%torrentfile%.torrent
    MsgBox, The target file does not exist


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 6th, 2009, 11:54 am 
Offline

Joined: September 10th, 2009, 5:54 pm
Posts: 203
Thanks for the reply, but this is not what I need, I want to watch if a program is downloading, uTorrent was an example if someone wanted to try to help.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 6th, 2009, 3:06 pm 
Offline

Joined: May 12th, 2009, 2:37 pm
Posts: 640
Location: Gloucester UK
Try using Windows Spy to see if a Control changes text when the program is downloading.
You can then monitor the text of this control and act accordingly.

If there isn't a control which changes text you could also try getting the text from the window and parsing that to see when the priogram is downloading


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 7th, 2009, 8:52 pm 
Offline

Joined: January 22nd, 2009, 3:43 pm
Posts: 84
from the command prompt: netstat -b and netstat -e give you statistics from traffic and ports used by programs, you could ahk RUN netstat -b >log.txt make logfiles and have ahk read the logfiles for inspection. Not easy job, but possible...


Last edited by Scratch on November 7th, 2009, 8:55 pm, edited 1 time in total.

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

Joined: September 10th, 2009, 5:54 pm
Posts: 203
Oh Scratch.. That's too advanced for me, lol
Noob here :D


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

Joined: January 22nd, 2009, 3:43 pm
Posts: 84
well to be honest, I havent done it before :D but i got a very crude example to work that sees if utorrent is active

Code:
!q::
filedelete c:\netlog.txt  ; delete old logfile first
run %comspec%
sleep 200
send netstat -b > c:\netlog.txt{enter}
;
sleep 2000
send ^c{enter}  ; otherwise netstat takes too long creating the logfile
;
utorrentactive := FALSE
Loop, read, C:\netlog.txt
   {
       IfInString, A_LoopReadLine, utorrent.exe, utorrentactive := TRUE
   }
if NOT utorrentactive
   msgbox Utorrent is not active  ; or start your downloadcode here
else
   msgbox Utorrent is active
return


just do a netstat when a program is downloading and check the logfile for recognizable string that you put where i put A_loopReadLine, (put your searchstring here)

The searchstring could also be a portnumber that the program uses when downloading or uploading a file.


Last edited by Scratch on November 7th, 2009, 9:52 pm, edited 1 time in total.

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

Joined: September 10th, 2009, 5:54 pm
Posts: 203
Well.. I tried it and played around with it, its not really working..

-All I see in the log file is a list of Firefox, nothing else!
-And a command prompt pops up evertime and doesn't go away.

I thought detecting a program that's downloading is much easier than this :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 7th, 2009, 10:15 pm 
Offline

Joined: January 22nd, 2009, 3:43 pm
Posts: 84
firefox shows up in the netlog all the time when active, on port 80, however i noticed when downloading and you do a netstat it uses port 443 as well, this can be your search string, you can add
Code:
Send Exit{enter}
to close the command window

Change
Code:
 netstat -b


to:
Code:
 netstat -b -n
to capture the portnumber to the logfile so that the log reads: blablabla.... firefox.exe:443 ...blablba...


Last edited by Scratch on November 7th, 2009, 10:29 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 7th, 2009, 10:28 pm 
Offline

Joined: September 10th, 2009, 5:54 pm
Posts: 203
But I don't see the other programs that ARE running AND downloading in that logfile

Eh! :?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 7th, 2009, 10:31 pm 
Offline

Joined: January 22nd, 2009, 3:43 pm
Posts: 84
what programs would that be? Not hidden trojan downloaders i hope :D

....or maybe the programs use UDP connections instead of TCP, do a netstat -p UDP > logfile1.txt during and after download, logfile2.txt and compare the logfiles if any udp connections were made and closed afterwards, these could become the searchcriteria then.


Last edited by Scratch on November 7th, 2009, 10:56 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 7th, 2009, 10:37 pm 
Offline

Joined: September 10th, 2009, 5:54 pm
Posts: 203
I don't see both (uTorrent and Newsleecher) and they are both running and downloading.

I tried to enter netstat -b manually in command prompt and watched command prompt box.. On enter I got Firefox, like 4 entries or so, then 30-40 seconds later it started giving me entries of uTorrent every 20 seconds or so, but no Newsleecher to be mentioned.

Weird!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 8th, 2009, 1:13 am 
Offline

Joined: July 18th, 2006, 12:18 pm
Posts: 403
if uTorrent is an example, Your gona need to tell us which program you actually want to monitor.. Since nothing reliable can be coded. Parsing netstat from the command link isnt efficient.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 8th, 2009, 1:22 am 
Offline

Joined: January 22nd, 2009, 3:43 pm
Posts: 84
Agreed, netstat takes much longer time to write a logfile than i anticipated and a lot of hard to decipher spaghetti output....Better use a dedicate network monitor that triggers an external program when it detects the download port/protocol being used or idle

However, In Newsleecher, there is an option to configure the download queue to run a commandline program when the queue is empty, iow: not downloading.

http://www.binaries4all.com/newsleecher/downloading.php

This could be an ahk script or any executable of your choosing.

Also, i've found a freeware network monitor that allows triggering external programs depending on measured traffic (see proactive alarms)

http://www.objectplanet.com/probe/

These programs often assume more than average understanding of networking protocols, but if you watch carefully what happens during a download, with a little trial and error you should be able to assign a trigger to that without having in depth knowledge of whats being displayed...


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Leef_me, Pulover, rbrtryn, XstatyK, Yahoo [Bot] and 52 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