Private Declare Function GetForegroundWindow Lib "user32.dll" () As Long
Private Declare Function FindWindowEx Lib "user32.dll" _
Alias "FindWindowExA" ( _
ByVal hwndParent As Long, _
ByVal hwndChildAfter As Long, _
ByVal lpszClass As String, _
ByVal lpszWindow As String) As Long
Private Declare Function GetWindowText Lib "user32" _
Alias "GetWindowTextA" ( _
ByVal hwnd As Long, _
ByVal lpString As String, _
ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" _
Alias "GetWindowTextLengthA" ( _
ByVal hwnd As Long) As Long
Private Declare Function GetWindow Lib "user32.dll" ( _
ByVal hwnd As Long, _
ByVal wCmd As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
' Vorbereitung: Notepad (Editor) öffnen, ein paar Zeichen eintippen, STRG+F4 drücken.
' Daraufhin erscheint eine handelsübliche MessageBox. Diese nicht schließen.
Private Sub CommandButton1_Click()
Dim h1 As Long, i1 As Long, i2 As Long, p1 As String
' Ich starte diese Prozedur, wechsle anschließend zu Notepad und seiner MessageBox.
' 3 Sekunden sollten dafür reichen
Sleep (3000)
h1 = GetForegroundWindow ' Fenster mit aktuellem Fokus ermitteln
h1 = FindWindowEx(h1, 0&, "Static", vbNullString) ' Dort das erste STATIC-Kontrollelement ermitteln
For i2 = 1 To 2
i1 = GetWindowTextLength(h1) + 1 ' Länge des Kontrollelementtextes ermitteln
If i1 > 1 Then ' Ist es der Text oder ein Icon? (Icons haben keinen Text)
p1 = Space(i1) ' Nötigen Platz reserveren
i1 = GetWindowText(h1, p1, i1) ' Text auslesen
Debug.Print "Text: " & Left$(p1$, i1) ' ...und ausgeben
Exit For ' Geschafft! Schleife verlassen
Else
h1 = GetWindow(h1, 2) ' Nächstes Kontrollelement ermitteln, dieses sollte endgültig den Text enthalten
End If
Next i2
End Sub
VB6 Variable in anderen Sub übergeben
da_horscht 28.11.2009 - 99 Hits - 6 Antworten
VB6 Maximale zeilen beim FlexGrid-Element
hardy115 16.06.2008 - 50 Hits - 2 Antworten
einer Zelle in Excel noch einen Text zu ordnen
PollerX 10.11.2008 - 35 Hits - 1 Antwort
Java Text-Datei einlesen mit LineNumberReader
Hallo156 24.04.2009 - 1385 Hits - 2 Antworten
VBA in VB6 umwandeln?
dersuchendeX09 28.11.2009 - 706 Hits - 2 Antworten