Results 1 to 8 of 8

Thread: [RESOLVED] Shutdown computer after downloads

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2006
    Posts
    50

    Resolved [RESOLVED] Shutdown computer after downloads

    I'm using Visual basic 6 and I want to make a program that shuts down the computer automatically after I finish downloading so I can download overnight if I need to. I know how to shutdown the computer with VB, and I got a program the shuts the computer down after a certain time. What I want is to shut the computer down immediately after my internet is inactive for 10 seconds.

    My problem is, I need my program to receive all the incoming data from downloading or detect the internet traffic so that my program knows when the computer's internet is inactive. The only way I can think of is Winsock, but it cannot receive all the incoming data or detect the internet traffic.
    Last edited by evan29; Jan 2nd, 2007 at 06:24 AM.

  2. #2
    New Member
    Join Date
    Dec 2006
    Posts
    6

    Re: Shutdown computer after downloads

    Interesting topic....
    Could you please advise from where are you downloading the data?
    is it an FTP site ? a P2P site? Web Server ?
    It is not so important , but it can give a starting point...

  3. #3
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Shutdown computer after downloads

    You could monitor packets being received to the computer.

    Here is a raw packet sniffer made in just VB:
    http://www.pscode.com/vb/scripts/Sho...46567&lngWId=1

    I think it only detects packets being received, and not sent. But that should work, as it's rare to send data on the internet and not receive anything after...


    Alternatively, you might be able to use code from a bandwidth monitor program. I've never looked at the code for one of these so I'm not sure exactly how they work.

    http://www.pscode.com/vb/scripts/Bro...t=Alphabetical

  4. #4

    Thread Starter
    Member
    Join Date
    Dec 2006
    Posts
    50

    Re: Shutdown computer after downloads

    Thanks DigiRev, I'll try it out. If you want I can upload the source code or the whole project when I'm done. This program will prove to be useful for me and can also be useful for everyone here that download a bunch of stuff.

    EDIT: This code is sort of confusing me because there is so much code in it. I couldn't actually get it to work in my new project file. Can you help me put the code together?

    This Code: http://www.pscode.com/vb/scripts/Sh...=46567&lngWId=1
    I got confused so I just put all those modules and class modules into my project, and some of that code of the Main Form. I also got the references that were needed. No components seemed like they were needed.

    This Code: http://www.pscode.com/vb/scripts/Br...rt=Alphabetical
    I have no idea how this code works.

    Make something like changing a text box whenever the computer receives that data. The content of data is not so important, its just the part where my program detects incoming data that is important - so that my program would be compatible with any downloading program, like your internet browser or your download manager or even P2P programs. Could there any API calls that would be possible to do this with? I'm not experienced with API calls but it may be easier, otherwise I'll stay away from API calling for this program.
    Last edited by evan29; Jan 3rd, 2007 at 08:04 AM.

  5. #5
    Fanatic Member sessi4ml's Avatar
    Join Date
    Nov 2006
    Location
    Near San Francisco
    Posts
    958

    Re: Shutdown computer after downloads

    Evan, I had thoughts about download and shut-down program. I was looking at the CPU load, or when an active job stopped being active or watching the packets.
    With a lot of Vbforms help, I created? more like assembled and posted the Shut-Down code. I am currious to see your direction.

  6. #6
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Shutdown computer after downloads

    I was able to pull the class modules from one of those bandwidth monitor programs and use them to see if the internet is idle.

    It does this by checking bytes sent/received and if they don't change for 10 seconds then it will shut down the computer.

    There's code for shutting down the computer on these forums and on the internet if you search.

    All you have to do is put the shut down code in the tmrWait() procedure where the comment says
    VB Code:
    1. 'Put shutdown code here.
    .

    You can also change the SECONDS constant to however many seconds you want to wait before shutting down.

    If you need any help let us know.
    Last edited by DigiRev; Mar 26th, 2007 at 02:55 AM.

  7. #7

    Thread Starter
    Member
    Join Date
    Dec 2006
    Posts
    50

    Resolved Re: Shutdown computer after downloads

    Thanks DigiRev!

    I added "quitWindows (EWX_SHUTDOWN)" into the tmrWait and added my simple shutdown module and it works perfectly. I also added a start/stop button.

    Here it is and it works perfectly :P. The interface is kind of small but I'll upload it so if anyone wants a program like this they can get it here. Save your work before starting it
    Attached Files Attached Files
    Last edited by evan29; Jan 5th, 2007 at 05:33 AM. Reason: Update Code

  8. #8
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: [RESOLVED] Shutdown computer after downloads

    Cool.

    Glad you got it working.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width