PavelO
Newbie | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Всем привет. Мои вопросы касаются всех продвинутых пользователей VBA 1. Почему через следующий код не выдает имя заголовка окна? Declare Function WindowFromPoint Lib "user32.dll" (ByVal xPoint As Long, ByVal yPoint As Long) As Long Declare Function GetCursorPos Lib "user32.dll" (lpPoint As POINTAPI) As Long Declare Function GetActiveWindow Lib "user32.dll" () As Long Declare Function GetWindowRect Lib "user32.dll" (ByVal hwnd As Long, lpRect As Rect) As Long Declare Function Rectangle Lib "gdi32.dll" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long Declare Function GetCursor Lib "user32.dll" () As Long Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Type Rect left As Long top As Long right As Long bottom As Long End Type Type POINTAPI x As Long y As Long End Type Private Sub CommandButton1_Click() Dim mousepos As POINTAPI Dim wintext As String, slength As Long Dim hwnd As Long Dim retval As Long Dim titlebar As String SendKeys "%{TAB}", True retval = GetCursorPos(mousepos) hwnd = WindowFromPoint(mousepos.x, mousepos.y) If hwnd = 0 Then MsgBox "Çäåñü íè÷åãî íåò." End End If Dim r As Rect retval = GetWindowRect(hwnd, r) Sheets(1).Cells(1, 1) = r.right Sheets(1).Cells(2, 1) = r.left Sheets(1).Cells(3, 1) = r.bottom Sheets(1).Cells(4, 1) = r.top titlebar = String$(256, " ") slength = GetWindowText(hwnd, titlebar, 255) titlebar = left$(titlebar, InStr(titlebar, vbNullChar) - 1) Sheets(1).Cells(5, 1) = titlebar End Sub |