07-31-2011, 11:53 PM
(This post was last modified: 08-01-2011, 12:00 AM by AceInfinity.)
I was fooling around some more with it today, checking different windows messages and processes with Spy++ and I found out how to send the windows message to close the program with the window Title in Textbox1.Text
Here is my code:
If you add that as a button, and you open Notepad and type "Untitled - Notepad" into Textbox1 before pressing the button, it will close notepad, assuming the title of that window for notepad is "Untitled - Notepad" in the Notepad class.
It will actually close any window if you get the proper window name.
Here is my code:
Code:
Dim hWnd As Integer
hWnd = FindWindow(vbNullString, TextBox1.Text)
SendMSG(hWnd, WM_CLOSE, 0, 0)
If you add that as a button, and you open Notepad and type "Untitled - Notepad" into Textbox1 before pressing the button, it will close notepad, assuming the title of that window for notepad is "Untitled - Notepad" in the Notepad class.
It will actually close any window if you get the proper window name.