Private Declare Function GETWINDOWTEXT Lib "user32" Alias "GetWindowTextA"(ByVal hwnd As Integer, ByVal lpString As String, ByVal cch As Integer) As Integer
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"(ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private 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
Private Declare Function SetForegroundWindow Lib "user32.dll" (ByVal hwnd As Integer) As Integer
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sCaption As New VB6.FixedLengthString(256) Dim String w/ 256 Spaces In Memory, Is There A .Net Way To Do This?
Dim hwnd As Long = FindWindow("IEFrame", vbNullString) Finds IE Window By Container Name, "IEFrame"
If Not hwnd = 0 Then Tests If Window Exists
SetForegroundWindow(hwnd) Brings Window To Foreground
GETWINDOWTEXT(hwnd, sCaption.Value, 256) Get The Text From That Window, For Testing Code... Not Functionally Needed
MsgBox(sCaption.Value) Show The Value Of The Caption, For Testing Code... Not Functionally Needed
The Following 5 Lines Of Code Are What Seem To Be Causing An Issue.
Im Trying To "Drill" Into The IE Window And Search For The URL Address
Bar Portion Of The Window. This Doesnt Seem To Be Working Correctly.
What Am I Doing Wrong With These FindWindowExs?
Dim Worker As Long = FindWindowEx(hwnd, 0, "WorkerW", vbNullString) Supposed To Find The Component W/ The Caption "WorkerW" Within The IE Window
Dim ToolBar As Long = FindWindowEx(Worker, 0, "rebarwindow32", vbNullString) Supposed To Find The Component W/ The Caption "rebarwindow32" Within The "WorkerW" Component
Dim ComboBoxEx As Long = FindWindowEx(ToolBar, 0, "comboboxex32", vbNullString) Supposed To Find The Component W/ The Caption "comboboxex32" Within The "rebarwindow32" Component
Dim Combo As Long = FindWindowEx(ComboBoxEx, 0, "combobox", vbNullString) Supposed To Find The Component W/ The Caption "combobox" Within The "comboboxex32" Component
Dim Edit As Long = FindWindowEx(Combo, 0, "Edit", vbNullString) Supposed To Find The Component W/ The Caption "Edit" (This Is Actually The URL Address Bar From Which Im Trying To
Pull The Text From) Within The "combobox" Component
Here Is Where I Would Like To Pull The Text From The "Edit"
Component (URL Address Bar Text) And Then Show The Value In
A Message Box
End If
End Sub