AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Check If Program Is Downloading

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Gauss



Joined: 10 Sep 2009
Posts: 203

PostPosted: Thu Nov 05, 2009 6:47 pm    Post subject: Check If Program Is Downloading Reply with quote

Is there a way to check if a program is downloading? and if not then do something?
uTorrent for example
Back to top
View user's profile Send private message
Scratch



Joined: 22 Jan 2009
Posts: 72

PostPosted: Fri Nov 06, 2009 1:18 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Gauss



Joined: 10 Sep 2009
Posts: 203

PostPosted: Fri Nov 06, 2009 10:54 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
wooly_sammoth



Joined: 12 May 2009
Posts: 634
Location: Gloucester UK

PostPosted: Fri Nov 06, 2009 2:06 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Scratch



Joined: 22 Jan 2009
Posts: 72

PostPosted: Sat Nov 07, 2009 7:52 pm    Post subject: Reply with quote

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 Sat Nov 07, 2009 7:55 pm; edited 1 time in total
Back to top
View user's profile Send private message
Gauss



Joined: 10 Sep 2009
Posts: 203

PostPosted: Sat Nov 07, 2009 7:54 pm    Post subject: Reply with quote

Oh Scratch.. That's too advanced for me, lol
Noob here Very Happy
Back to top
View user's profile Send private message
Scratch



Joined: 22 Jan 2009
Posts: 72

PostPosted: Sat Nov 07, 2009 8:37 pm    Post subject: Reply with quote

well to be honest, I havent done it before Very Happy 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 Sat Nov 07, 2009 8:52 pm; edited 1 time in total
Back to top
View user's profile Send private message
Gauss



Joined: 10 Sep 2009
Posts: 203

PostPosted: Sat Nov 07, 2009 8:50 pm    Post subject: Reply with quote

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 Very Happy
Back to top
View user's profile Send private message
Scratch



Joined: 22 Jan 2009
Posts: 72

PostPosted: Sat Nov 07, 2009 9:15 pm    Post subject: Reply with quote

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 Sat Nov 07, 2009 9:29 pm; edited 1 time in total
Back to top
View user's profile Send private message
Gauss



Joined: 10 Sep 2009
Posts: 203

PostPosted: Sat Nov 07, 2009 9:28 pm    Post subject: Reply with quote

But I don't see the other programs that ARE running AND downloading in that logfile

Eh! Confused
Back to top
View user's profile Send private message
Scratch



Joined: 22 Jan 2009
Posts: 72

PostPosted: Sat Nov 07, 2009 9:31 pm    Post subject: Reply with quote

what programs would that be? Not hidden trojan downloaders i hope Very Happy

....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 Sat Nov 07, 2009 9:56 pm; edited 2 times in total
Back to top
View user's profile Send private message
Gauss



Joined: 10 Sep 2009
Posts: 203

PostPosted: Sat Nov 07, 2009 9:37 pm    Post subject: Reply with quote

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!
Back to top
View user's profile Send private message
i3egohan



Joined: 18 Jul 2006
Posts: 403

PostPosted: Sun Nov 08, 2009 12:13 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Scratch



Joined: 22 Jan 2009
Posts: 72

PostPosted: Sun Nov 08, 2009 12:22 am    Post subject: Reply with quote

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...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group