AW: edit fenster auslesen
29.11.2007 14:11:00
Renee
Hi Klaro,
bei mir wollte die umschalt Taste
nicht ordentlich arbeiten -deswegen
... ist eine ziemlich fade Ausrede, wenn vorher und nachher in normaler Gross- Kleinschreibung geschrieben wurde ;-)
So kannst Du den Windows-Handle bestimmen:
Option Explicit
Private Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Long) As _
Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal _
hWnd As Long) 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 FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, _
ByVal lpWindowName As Long) As Long
Public Sub GetWindowList()
Const cWindowTitle = "command.com"
Dim hWnd As Long
Dim tTitle As String
Dim bFound As Boolean
hWnd = FindWindow(ByVal 0&, ByVal 0&)
hWnd = GetWindow(hWnd, 0)
Do
tTitle = GetWindowTitle(hWnd)
If Trim(LCase(tTitle)) "" And InStr(LCase(tTitle), LCase(cWindowTitle)) 0 Then
MsgBox "Handle: " & hWnd, vbOKOnly, cWindowTitle
bFound = True
End If
hWnd = GetWindow(hWnd, 2)
Loop Until hWnd = 0
If Not (bFound) Then MsgBox "Kein Handle für " & cWindowTitle & " gefunden!", vbOKOnly + _
vbExclamation
End Sub
Private Function GetWindowTitle(ByVal hWnd As Long) As String
Dim lTxtLen As Long, tTmp As String
lTxtLen = GetWindowTextLength(hWnd) + 1
tTmp = Space(lTxtLen)
lTxtLen = GetWindowText(hWnd, tTmp, lTxtLen)
GetWindowTitle = Left(tTmp, Len(tTmp) - 1)
End Function
GreetZ Renee