Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Windows Messages - SendMessage (Finding/Sending Windows Messages) - By Ace
#7
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:
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.

[Image: ijfRfg.gif]
Reply


Messages In This Thread
RE: Windows Messages - SendMessage (Finding/Sending Windows Messages) - By Ace - by AceInfinity - 07-31-2011, 11:53 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Preview] Windows 7 Tools [VB.NET] ƃu∀ ıʞƃu∀ 4 3,649 10-14-2014, 11:55 AM
Last Post: 'Onam
  [Discuss]Console Coding Or Windows Form? [Discuss] Business.Gov 6 2,212 10-01-2012, 11:27 PM
Last Post: XDarkCoder
  Download Updates & Broadcast Messages SOURCE kpn37z 0 630 06-24-2012, 04:39 AM
Last Post: kpn37z
  Code Challenge - Created by Ace AceInfinity 5 1,713 04-24-2012, 10:27 AM
Last Post: AceInfinity
  File Profiler Demo - Preview - Developed by Ace AceInfinity 4 1,420 12-30-2011, 08:17 PM
Last Post: AceInfinity

Forum Jump:


Users browsing this thread: 4 Guest(s)