PDA

View Full Version : problem with api call



vitor
07-31-2018, 09:02 AM
hi.

can you help me, clarifying why the code below, although without errors, doesn't produce any result?



Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 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 GetKeyState Lib "user32" (ByVal nVirtkey As Long) As Integer


Sub capture()
Dim lngHWnd As Long
Dim lngHWndChild As Long
Dim lngIndex As Long
Dim lngDlgItem As Long
Dim lngTextLength As Long
Dim strText As String

lngHWnd = FindWindow(vbNullString, "Sem título - Bloco de notas") ' Notepad

lngHWndChild = FindWindowEx(lngHWnd, 0&, "Edit", vbNullString)

lngTextLength = GetWindowTextLength(lngHWndChild)

strText = Space(lngTextLength)
GetWindowText lngHWndChild, strText, lngTextLength + 1

Debug.Print strText

End Sub


according to the microsoft spy++,
Handle: 001A05B4
Caption: 133345
Class: Edit