-
Jan 2nd, 2021, 12:16 PM
#1
Thread Starter
Junior Member
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.
-
Jan 2nd, 2021, 01:07 PM
#2
Thread Starter
Junior Member
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)
-
Jan 3rd, 2021, 04:05 AM
#3
Re: VB.NET How to Title Get Exe
You can close the thread by clicking on "Thread Tools" just above your first post.
-
Jan 3rd, 2021, 10:43 AM
#4
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
-
Jan 3rd, 2021, 11:20 AM
#5
Re: VB.NET How to Title Get Exe
Indeed. A slip of the keyboard ...
-
Jan 4th, 2021, 11:19 PM
#6
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|