AW: Webseite positionieren
27.11.2017 18:15:46
Nepumuk
Hallo,
dazu benötige ich erst mal den Klassennamen des Google-Chrome Fensters. Denn den lade ich mir keinesfalls auf meinen Rechner.
Also, lass folgendes Makro laufen und schreib mir was in Spalte B neben der Überschrift des Chrome-Browsers in Spalte C steht.
Option Explicit
Private Declare Function EnumWindows Lib "user32.dll" ( _
ByVal lpEnumFunc As Long, _
ByVal lParam As Long) As Boolean
Private Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" ( _
ByVal hwnd As Long, _
ByVal lpString As String, _
ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" ( _
ByVal hwnd As Long) As Long
Private Declare Function GetClassName Lib "user32.dll" Alias "GetClassNameA" ( _
ByVal hwnd As Long, _
ByVal lpClassName As String, _
ByVal nMaxCount As Long) As Long
Private Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" ( _
ByVal hwnd As Long, _
ByVal nIndex As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const WS_VISIBLE = &H10000000
Private Const WS_BORDER = &H800000
Private llngRow As Long
Public Sub Start()
llngRow = 1
Columns("A:C").ClearContents
With Range("A1:C1")
.Value = Array("Hwnd", "Klasse", "Caption")
.Font.Bold = True
End With
Call EnumWindows(AddressOf WindowCallBack, ByVal 0&)
Columns("A:C").AutoFit
Tabelle1.Sort.SortFields.Clear
Tabelle1.Sort.SortFields.Add Key:=Columns(2)
With Tabelle1.Sort
.SetRange Columns("A:C")
.Header = xlYes
.MatchCase = False
.Apply
End With
End Sub
Private Function WindowCallBack(ByVal lngHwnd As Long, ByVal lngParam As Long) As Long
Dim strCaption As String, strClassName As String
Dim lngReturn As Long, lngStyle As Long
lngStyle = GetWindowLong(lngHwnd, GWL_STYLE)
If lngStyle And (WS_VISIBLE Or WS_BORDER) <> 0 Then
strClassName = Space$(256)
lngReturn = GetClassName(lngHwnd, strClassName, 256)
lngReturn = GetWindowTextLength(lngHwnd)
strCaption = Space$(lngReturn)
Call GetWindowText(lngHwnd, strCaption, lngReturn + 1)
llngRow = llngRow + 1
Cells(llngRow, 1).Resize(1, 3) = Array(lngHwnd, Trim$(strClassName), strCaption)
End If
WindowCallBack = 1
End Function
Gruß
Nepumuk