
![]() |
Наши проекты:
Журнал · Discuz!ML · Wiki · DRKB · Помощь проекту |
|
ПРАВИЛА | FAQ | Помощь | Поиск | Участники | Календарь | Избранное | RSS |
[216.73.216.207] |
![]() |
|
Страницы: (3) 1 [2] 3 все ( Перейти к последнему сообщению ) |
Сообщ.
#16
,
|
|
|
Сообщ.
#17
,
|
|
|
Filka, спасибо огромное, буду смотреть
|
Сообщ.
#18
,
|
|
|
Пожалуйста.
|
Сообщ.
#19
,
|
|
|
Сообщ.
#20
,
|
|
|
Надо не сразу ToolBarWindow32 писать, а спускаться по иерархии окон, т.е. от родительского CabinetWClass, потом WorkerW, потом ReBarWindow32 и т.д.
|
Сообщ.
#21
,
|
|
|
Filka, да, именно так:
![]() ![]() hndExpl = FindWindow("CabinetWClass", vbNullString) hndExpl1 = FindWindowEx(hndExpl, 0, "WorkerW", vbNullString) hndExpl2 = FindWindowEx(hndExpl1, 0, "ReBarWindow32 (Toolbar)", vbNullString) в итоге: hndExpl2 =0 |
Сообщ.
#22
,
|
|
|
![]() ![]() hndExpl = FindWindow("CabinetWClass", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "WorkerW", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "ReBarWindow32", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "Address Band Root", vbNullString) '... и т.д. hndExpl = FindWindowEx(hndExpl, 0, "ToolBarWindow32", vbNullString) |
Сообщ.
#23
,
|
|
|
Filka, получилось, но не могу теперь текст вывести:
![]() ![]() Sub findhead() Dim hndExpl As Long Dim s As String, iTxtLen As Long hndExpl = FindWindow("CabinetWClass", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "WorkerW", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "ReBarWindow32", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "Address Band Root", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "msctls_progress32", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "Breadcrumb Parent", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "ToolBarWindow32", vbNullString) iTxtLen = SendMessage(hndExpl, WM_GETTEXTLENGTH, 0, 0) iTxtLen = iTxtLen + 1 s = Space$(iTxtLen) iTxtLen = SendMessage(hndExpl, WM_GETTEXT, iTxtLen, ByVal s) MsgBox s End Sub Добавлено всё, разобрался ![]() ![]() Ret = GetWindowTextLength(hndExpl) sSave = Space(Ret) GetWindowText hndExpl, sSave, Ret + 1 Me.Caption = sSave Добавлено Ещё один момент, если у меня открыто 5 проводников, то как мне их заголовки все вывести последовательно? |
Сообщ.
#24
,
|
|
|
EnumWindows
|
Сообщ.
#25
,
|
|
|
Filka, написал, как-то опять не так выводит. Повторяет одну и ту же директорию n-ое число раз, при том, что открыто 2 директории. В чём опять ошибка?
![]() ![]() ' Модуль Option Explicit Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Boolean Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long 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 Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean Dim sSave As String Dim Ret As Long Dim hndExpl As Long Dim iTxtLen As Long hndExpl = FindWindow("CabinetWClass", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "WorkerW", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "ReBarWindow32", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "Address Band Root", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "msctls_progress32", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "Breadcrumb Parent", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "ToolBarWindow32", vbNullString) Ret = GetWindowTextLength(hndExpl) sSave = Space(Ret) GetWindowText hndExpl, sSave, Ret + 1 Form1.Text1.Text = Form1.Text1.Text + sSave + vbCrLf EnumWindowsProc = True End Function ' Форма Option Explicit Private Sub Form_Load() Text1.Text = vbNullString EnumWindows AddressOf EnumWindowsProc, ByVal 0& End Sub |
Сообщ.
#26
,
|
|
|
А так?
![]() ![]() Option Explicit Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Boolean Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long 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 Declare Function GetClassName Lib "user32.dll" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean Dim sSave As String Dim Ret As Long Dim hndExpl As Long Dim ClassName As String ClassName = Space(255) Ret = GetClassName(hwnd, ClassName, 255) ClassName = Left(ClassName, Ret) If ClassName = "CabinetWClass" Then hndExpl = FindWindowEx(hwnd, 0, "WorkerW", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "ReBarWindow32", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "Address Band Root", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "msctls_progress32", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "Breadcrumb Parent", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "ToolBarWindow32", vbNullString) Ret = GetWindowTextLength(hndExpl) sSave = Space(Ret) GetWindowText hndExpl, sSave, Ret + 1 Form1.Text1.Text = Form1.Text1.Text + sSave + vbCrLf End If EnumWindowsProc = True End Function |
Сообщ.
#27
,
|
|
|
Filka, спасибо огромное, всё получилось!
|
Сообщ.
#28
,
|
|
|
Пожалуйста
![]() |
Сообщ.
#29
,
|
|
|
На Windows 7 всё заработало. Стал для Windows XP писать, и ничего не выходит. Подскажите, пожалуйста, в чём ошибка? Скриншот прилагаю.
![]() ![]() 'модуль Option Explicit Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Boolean Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long 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 Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean Dim sSave As String Dim Ret As Long Dim hndExpl As Long Dim iTxtLen As Long hndExpl = FindWindow("CabinetWClass", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "WorkerW", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "ReBarWindow32", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "ComboBoxEx32", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "ComboBox", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "Edit", vbNullString) Ret = GetWindowTextLength(hndExpl) sSave = Space(Ret) GetWindowText hndExpl, sSave, Ret + 1 Form1.Text1.Text = Form1.Text1.Text + sSave + vbCrLf EnumWindowsProc = True End Function 'форма Option Explicit Private Sub Form_Load() Text1.Text = vbNullString EnumWindows AddressOf EnumWindowsProc, ByVal 0& End Sub Прикреплённая картинка
![]() Добавлено Проблема с этой строкой: ![]() ![]() Ret = GetWindowTextLength(hndExpl) |
Сообщ.
#30
,
|
|
|
![]() ![]() Option Explicit Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Boolean 'Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long 'Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long 'Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long 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 Declare Function GetClassName Lib "user32.dll" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long Const WM_GETTEXTLENGTH As Long = &HE Const WM_GETTEXT As Long = &HD Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean Dim sSave As String Dim Ret As Long Dim hndExpl As Long Dim ClassName As String ClassName = Space(255) Ret = GetClassName(hwnd, ClassName, 255) ClassName = Left(ClassName, Ret) If ClassName = "CabinetWClass" Then hndExpl = FindWindowEx(hwnd, 0, "WorkerW", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "ReBarWindow32", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "ComboBoxEx32", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "ComboBox", vbNullString) hndExpl = FindWindowEx(hndExpl, 0, "Edit", vbNullString) Ret = SendMessage(hndExpl, WM_GETTEXTLENGTH, 0, 0) sSave = Space(Ret + 1) SendMessage hndExpl, WM_GETTEXT, Ret + 1, ByVal sSave sSave = Left(sSave, Ret) + vbCrLf Form1.Text1.Text = Form1.Text1.Text + sSave End If EnumWindowsProc = True End Function salieri, подошло? |