Detect whether a program is open, if it is - start a timer...
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Detect whether a program is open, if it is - start a timer...

  1. #1
    Join Date
    Jan 2011
    Posts
    2

    Exclamation Detect whether a program is open, if it is - start a timer...

    Objective : Time how long a user has been on the internet.


    I have never delved this deep into Visual Studio. I am suing Visual Basic 2010 Express. Please move it if you need to.

    I want to have a program - that will detect running processes. If Internet Explorere EXE or Chrome or FireFox exe or any other browser is installed - as soon as that process starts the timer will appear.

    When those processes are closed by the user the timer stops counting. This is possible but i dont know how. But i only want it to time just one internet process because timing them all when they are openend up at different times could cause bugs. Unless on the time form you have 1 timer for IE, 1 for FFox, 1 for Chrome 1 for Opera.... etc

    Please can someone help me.
    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,984

    Re: Detect whether a program is open, if it is - start a timer...

    That's harder, as you wouldn't know about any future browsers. Maybe check the Internet Connectivity? Mine shows 4 days...
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jan 2011
    Posts
    2

    Wink Re: Detect whether a program is open, if it is - start a timer...

    Yeah it is hard but i've done like 80 %

    I can detect a program if its open start a timer and repeat this for other browsers like chrome, IE, FireFox & Safari will add more.

    If the processes are not open then the timer wont start it works.

    Only thing left to do is detect if the process starts/stops at a later time to then effect a timer.

    I am determined to do it

  4. #4
    Join Date
    Jan 2011
    Posts
    3

    Re: Detect whether a program is open, if it is - start a timer...

    Well, this code shows all processes... you have only to search for your browser and then activate or deactivate the timer

    Code:
    Dim psList() As Process
            psList = Process.GetProcesses()
            For Each p As Process In psList
                ListBox1.Items.Add(p.Id.ToString() + " " + p.ProcessName)
            Next

  5. #5
    Join Date
    Jan 2011
    Posts
    3

    Talking Re: Detect whether a program is open, if it is - start a timer...

    well to start I think you have your own PC try opening it using your own own project application
    by using shell as well as your timer

    Code:
    Shell("C:\Program Files\Opera\opera.exe")
    Timer1.start

    something like that.

  6. #6
    Join Date
    Jan 2011
    Posts
    3

    Re: Detect whether a program is open, if it is - start a timer...

    Quote Originally Posted by cyberzen View Post
    well to start I think you have your own PC try opening it using your own own project application
    by using shell as well as your timer

    Code:
    Shell("C:\Program Files\Opera\opera.exe")
    Timer1.start

    something like that.
    Or

    Make an invisible form1 then
    Code:
    Public Class Form1
     
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Shell("C:\Program Files\Opera\opera.exe")
            Form2.show()
            Me.Hide()
        End Sub
    End Class
    Put your timer codes on form2
    and make a link for this application then replace it with the Icon and shortcut of the webbrowser on your desktop

    ^_^

Tags for this Thread

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center