PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

[OT] Window Handles in VB.Net

Wondering if anyone here has a general knowledge of the Windows API and .NET. I'm currently attempting to hack my way through finding a hidden Window, and being able to read the lines from a textbox, and change the value of/submit with enter an editbox beneath it.

I'm a complete idiot when it comes to any "real" programming language, but here's what I've managed so far:

Code:

Module Module1
Private Declare Auto Function FindWindow Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private Declare Auto Function GetWindowText Lib "user32" (ByVal hwnd As IntPtr, ByVal lpString As String, ByVal cch As Integer) As Integer
Private Declare Auto Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long

Private Function GetETConsole() As String
Dim Consolehwnd As IntPtr = FindWindow(vbNullString, "ET Console")
If Consolehwnd.Equals(IntPtr.Zero) Then Return "Not running"

Dim lpText As New String(Chr(0), 100)

Dim intLength As Integer = GetWindowText(Consolehwnd, lpText, lpText.Length)
If (intLength <= 0) OrElse (intLength > lpText.Length) Then Return "Unknown"

Dim strTitle As String = lpText.Substring(0, intLength)

Return strTitle
End Function

Public Sub Main()
Console.WriteLine(GetETConsole())
Console.ReadLine()
End Sub

End Module


Right now it just prints ET Console to the window, which is the proper title of the window I'm trying to mess with. Any help would be greatly appreciated!
Do you have Spy++? You can use it to figure out the hierarchy of the target window's controls. In your app, once you have the window handle for the edit box you can just call SetWindowText to change its contents.

Dan East
Grabbed something called WinID that seems to do something similar. I see a WC_EDIT for both of them, will have to do some more digging.