Webbrowser in Form without Control !!!! Years to late....

MsAccessNL

Member
Local time
Today, 03:14
Joined
Aug 27, 2022
Messages
216
I worked on this many years ago, my gut told me it should be possible, i was so close. Years later i solved the puzzle (bit to late..)Edit thread

We could have worked with the modern webbrowsers inside access for many years already, without using any control. I can also open Excel, Word, Outlook,Notepad and probaly every other program. Also other access databases. I want to post this and make a youtube. So please don't steal the topic (happened before..)


1760645738425.png
 
Last edited:
ny years already, without using any control. I can also open Excel, Word, Outlook,Notepad and probaly every other program
Well, sounds nice, but can you control (automate) those other applications in any meaningful way?
 
This is the chrome webbrowser, for those who don’tt like edge.
 
FYI, Daniel Pineault has posted a teaser on this topic specifically, in recent days.
 
Last edited:
After reading Daniel's post, I'm at a loss. What purpose does this serve?

@MsAccessNL, does your approach provide any additional benefits? When is the announced video coming up?
 
Been playing with Daniel Peanut's code…… As he states works well for some apps but not others.
Need to identify external apps without PID's

A few different options to consider maybe: -

Code:
'==========================
' Module: WindowIdentifier
' Purpose: Identify external app windows without relying on PID
'==========================

Option Compare Database
Option Explicit

' Windows API declarations
Private Declare PtrSafe Function EnumWindows Lib "user32" _
    (ByVal lpEnumFunc As LongPtr, ByVal lParam As LongPtr) As Long

Private Declare PtrSafe Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
    (ByVal hwnd As LongPtr, ByVal lpString As String, ByVal cch As Long) As Long

Private Declare PtrSafe Function GetClassName Lib "user32" Alias "GetClassNameA" _
    (ByVal hwnd As LongPtr, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long

Private Declare PtrSafe Function GetWindowThreadProcessId Lib "user32" _
    (ByVal hwnd As LongPtr, lpdwProcessId As Long) As Long

' Store matched windows
Public MatchedWindows As Collection

' Entry point: call this to find windows by title or class
Public Sub FindWindowsByPattern(ByVal titlePattern As String, ByVal classPattern As String)
    Set MatchedWindows = New Collection
    EnumWindows AddressOf EnumWindowsProc, ByVal 0
    Debug.Print "Found " & MatchedWindows.Count & " matching windows."
End Sub

' Callback for EnumWindows
Private Function EnumWindowsProc(ByVal hwnd As LongPtr, ByVal lParam As LongPtr) As Long
    Dim winTitle As String, winClass As String
    winTitle = GetWindowTitle(hwnd)
    winClass = GetWindowClass(hwnd)

    ' Match patterns (case-insensitive)
    If (titlePattern <> "" And InStr(1, winTitle, titlePattern, vbTextCompare) > 0) Or _
       (classPattern <> "" And InStr(1, winClass, classPattern, vbTextCompare) > 0) Then
        MatchedWindows.Add hwnd
        Debug.Print "Match: hWnd=" & hwnd & " | Title=" & winTitle & " | Class=" & winClass
    End If

    EnumWindowsProc = 1 ' Continue enumeration
End Function

' Helpers to get window title and class
Private Function GetWindowTitle(ByVal hwnd As LongPtr) As String
    Dim buffer As String * 256
    Dim length As Long
    length = GetWindowText(hwnd, buffer, Len(buffer))
    If length > 0 Then GetWindowTitle = Left$(buffer, length)
End Function

Private Function GetWindowClass(ByVal hwnd As LongPtr) As String
    Dim buffer As String * 256
    Dim length As Long
    length = GetClassName(hwnd, buffer, Len(buffer))
    If length > 0 Then GetWindowClass = Left$(buffer, length)
End Function
 

Attachments

Users who are viewing this thread

Back
Top Bottom