Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27212

Need Help Pressing A Button On A ToolbarWindow32 Using Win32 APIs

$
0
0
Hi,

I have this external app which I'm trying to click a button on its toolbar. I'm managing to successfully find the handle of the toolbar, but accordding to Spy++, the button on the toolbar is not a child window. What should I do to proceed? Here is my code so far -

Code:

Option Explicit On

Public Class Form1

    Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Integer, ByVal hWnd2 As _
    Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer

    Public bln_Loop As Boolean
    Public hwnd1, hwnd2, hwnd3 As Integer

    Public Sub cmd_Start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_Start.Click
        bln_Loop = False
        Do Until bln_Loop
            For Each p As Process In Process.GetProcesses
                If p.MainWindowTitle.Contains("Ascent Capture - Validation") Then
                    hwnd1 = CInt(p.MainWindowHandle)
                    hwnd2 = FindWindowEx(hwnd1, 0, "AfxControlBar70", "Batch Tools")
                    hwnd3 = FindWindowEx(hwnd2, 0, "ToolbarWindow32", "Batch Tools")
                End If
            Next
        Loop
    End Sub

    Public Sub cmd_Stop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_Stop.Click
        bln_Loop = True
    End Sub

End Class


Viewing all articles
Browse latest Browse all 27212


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>