Doppelte Webseite öffnen verhindern
01.12.2024 08:28:26
sigiF
Meine Makro läuft endlos,
Danke! Gruß Sigi
Declare PtrSafe Function AccessibleObjectFromWindow Lib "oleacc" (ByVal hwnd As Long, ByVal dwId As Long, ByRef riid As Any, ByRef ppvObject As Any) As Long
Declare PtrSafe Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Declare PtrSafe Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Sub ABC_Seite()
Dim edgePath As String
Dim adresse As String
Dim hwnd As Long
Dim hwndChild As Long
Dim className As String * 256
Dim url As String
Dim gefunden As Boolean
gefunden = False
adresse = "https://auskunft.abc.de" ' URL der Webseite
hwnd = FindWindowEx(0, 0, "Chrome_WidgetWin_1", vbNullString)
Do While hwnd > 0
Debug.Print "Starte die Schleife"
hwndChild = FindWindowEx(hwnd, 0, "Chrome_RenderWidgetHostHWND", vbNullString)
If hwndChild > 0 Then
Debug.Print "Aktuelles hwnd: " & hwnd
' Hier den URL des Tabs abrufen
url = GetTabURL(hwndChild)
If InStr(url, adresse) > 0 Then
gefunden = True
hwnd = 0 ' Setze hwnd auf 0, um die Schleife zu beenden
Exit Do
End If
End If
hwnd = FindWindowEx(0, 0, "Chrome_WidgetWin_1", vbNullString) ' Parent-Fenster auf 0 setzen
Loop
Debug.Print "Schleife beendet " & gefunden
If gefunden = False Then
edgePath = "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
Shell edgePath & " """ & adresse & """", vbNormalFocus
End If
End Sub
' Funktion zum Abrufen des URL des aktuellen Tabs
Private Function GetTabURL(ByVal hwndChild As Long) As String
Debug.Print GetTabURL
GetTabURL = "https://auskunft.abc.de" ' Hier den richtigen URL einfügen
End Function
Anzeige