dcsimg
Results 1 to 5 of 5

Thread: Getting a window's process name?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2009
    Posts
    435

    Getting a window's process name?

    How would I get a window's process name? For example, if im using firefox, and im on VBForums, I want my program to look for a window with a name of "VBForums - Visual Basic and VB .NET Discussions and More!" and then get its process name.

  2. #2
    Addicted Member ZenDisaster's Avatar
    Join Date
    Dec 2006
    Location
    Bay Area, CA
    Posts
    140

    Re: Getting a window's process name?

    Code:
            For Each MyProc As Process In Process.GetProcesses
                If MyProc.MainWindowTitle = "VBForums - Visual Basic and VB .NET Discussions and More!" Then
                    Return MyProc.ProcessName
                End If
            Next

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2009
    Posts
    435

    Re: Getting a window's process name?

    Quote Originally Posted by ZenDisaster View Post
    Code:
            For Each MyProc As Process In Process.GetProcesses
                If MyProc.MainWindowTitle = "VBForums - Visual Basic and VB .NET Discussions and More!" Then
                    Return MyProc.ProcessName
                End If
            Next
    How would I get a list of current windows?

  4. #4
    Addicted Member ZenDisaster's Avatar
    Join Date
    Dec 2006
    Location
    Bay Area, CA
    Posts
    140

    Re: Getting a window's process name?

    If you want a list of window titles you could use something like this;
    Code:
            For Each MyProc As Process In Process.GetProcesses
                If MyProc.MainWindowTitle <> "" Then ListBox1.Items.Add(MyProc.MainWindowTitle)
            Next

  5. #5
    New Member
    Join Date
    Apr 2009
    Posts
    7

    Re: Getting a window's process name?

    Quote Originally Posted by ZenDisaster View Post
    Code:
            For Each MyProc As Process In Process.GetProcesses
                If MyProc.MainWindowTitle = "VBForums - Visual Basic and VB .NET Discussions and More!" Then
                    Return MyProc.ProcessName
                End If
            Next

    I am using excel VBA. when i am running this code...getting the error as 'user-defined type not defined'.


    Can any body help?

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width