Register
Site Login
Site Search
Forums
Advertisement
Welcome to PocketMatrix. PocketMatrix is dedicated to providing the best online community for mobile device developers and enthusiests. What's new?

[OT] Window Handles in VB.Net


[OT] Window Handles in VB.Net

Postby sponge » Feb 18, 2007 @ 4:39pm

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: Select all









10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
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
25 lines; 0 keywds; 4 nums; 55 ops; 6 strs; 0 coms    Syntactic Coloring v0.4 - Dan East  


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!
holy internets batman.
User avatar
sponge
Not sponge
 
Posts: 12779
Joined: Jan 13, 2002 @ 8:04am
Location: New Hampshire


Postby Dan East » Feb 18, 2007 @ 8:27pm

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
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Postby sponge » Feb 18, 2007 @ 10:37pm

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.
holy internets batman.
User avatar
sponge
Not sponge
 
Posts: 12779
Joined: Jan 13, 2002 @ 8:04am
Location: New Hampshire


Return to Windows Mobile


Sort


Forum Description

A discussion forum for mobile device developers on the Windows Mobile platform. Any platform specific topics are welcome.

Moderators:

Dan East, sponge, Digby, David Horn, Kevin Gelso, RICoder

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron