Results 1 to 6 of 6

Thread: VB.NET How to Title Get Exe

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2020
    Posts
    21

    VB.NET How to Title Get Exe

    For example, I opened "Untitled - Notepad" and I want to detect the title of it and pass the name processbyname to textbox1. How can I do it? So when "Untitled - Notepad" comes up and it is active, I want to transfer the name of processbyname to textbox1.

    As soon as the "Untitled - Notepad" title comes up, I want it to automatically detect it and print it to textbox1 as a "notepad". So I want to processbyname.

    Thank you.

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Sep 2020
    Posts
    21

    Re: VB.NET How to Title Get Exe

    I find close thread pls, thank you

    Private Declare Auto Function FindWindowEx Lib "user32" (ByVal parentHandle As Integer, ByVal childAfter As Integer, ByVal lclassName As String, ByVal windowTitle As String) As Integer
    Private Declare Auto Function PostMessage Lib "user32" (ByVal hwnd As Integer, ByVal message As UInteger, ByVal wParam As Integer, ByVal lParam As Integer) As Boolean
    Dim WM_QUIT As UInteger = &H12
    Dim WM_CLOSE As UInteger = &H10
    Dim handle2 As Integer = FindWindowEx(0, 0, Nothing, "Untitled - Notepad")
    PostMessage(handle2, WM_QUIT, 0, 0)

  3. #3
    Fanatic Member
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    750

    Re: VB.NET How to Title Get Exe

    You can close the thread by clicking on "Thread Tools" just above your first post.

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: VB.NET How to Title Get Exe

    I don't think that's what they meant. You can't close a thread on the Thread Tools menu, anyways, you can just mark it as resolved.

    FindWindowsEx seems like it does the opposite of what you want: It can be used to get the windows handle of a window given the title. You want the title given the window, so FindWindowsEx seems a bit backwards. It also won't do anything as soon as the window pops up, so you'd have to be monitoring active windows by some means to do that.
    My usual boring signature: Nothing

  5. #5
    Fanatic Member
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    750

    Re: VB.NET How to Title Get Exe

    Indeed. A slip of the keyboard ...

  6. #6
    Lively Member
    Join Date
    Jan 2020
    Posts
    120

    Re: VB.NET How to Title Get Exe

    Have a look at the System.Diagnostics.Process class:

    Code:
    Process p = <Get process>
    Console.WriteLine(p.MainWindowTitle)
    Reference: link

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