VB.NET Setting an External Program’s Title window

I have been working on making some trainers for some games and I wanted a basic way of showing that a cheat was enabled.
I couldn’t figured out how to draw to the screen so I figured the title bar would be fine.

  1. Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hWnd As IntPtr, ByVal lpString As String) As Boolean
  2.  
  3. Public Sub SetTitleText(ByVal processName() As Process, ByVal textToSend As String)
  4.  
  5. For Each proc In processName
  6. SetWindowText(proc.MainWindowHandle, textToSend)
  7. Next
  8.  
  9. End Sub

The code above will allow you to set the title window to an external program.
An example on how to use it

  1. Dim notepad() As Process = Process.GetProcessesByName("notepad")
  2.  
  3. Private Sub btn_Notepad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Notepad.Click
  4. SetTitleText(notepad,"Insert some text here")
  5. End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *