Автор: rank1
Дата сообщения: 11.01.2008 12:01
Хочу поделиться со всеми VBшниками способом выдирания деклараций для api файлов.
1. Запускаем Excel
2. Добавляем 2 модуля
Модуль1
Код: Option Explicit
Declare Function SendMessage Lib [no]"user32.dll"[/no] _
Alias [no]"SendMessageA"[/no] _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
wParam As Any, _
lParam As Any) _
As Long
Declare Function FindWindow Lib [no]"user32.dll"[/no] Alias [no]"FindWindowA"[/no] _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) _
As Long
Declare Function FindWindowEx Lib [no]"user32.dll"[/no] _
Alias [no]"FindWindowExA"[/no] _
(ByVal hParent As Long, _
ByVal hChild As Long, _
ByVal lpszClassname As String, _
ByVal lpszWindow As String) _
As Long
Private Declare Sub Sleep Lib [no]"kernel32"[/no] (ByVal dwMS As Long)
Public Const WM_SETTEXT = &HC
Private Const WM_GETTEXT = &HD
Declare Function GetKeyState Lib [no]"user32"[/no] (ByVal nVirtKey As Long) As Integer
Const VK_CONTROL As Integer = &H11
Sub reader()
Dim hw
hw = InputBox([no]"GetHwnd"[/no], [no]"Type captured hwnd of F2 window"[/no], Empty)
If Trim(hw) = [no]""[/no] Then Exit Sub
Dim hwnd As Long: hwnd = CLng([no]"&H"[/no] & hw)
Dim pwd1 As String * 1024
Dim pwd2 As String * 1024
Dim s1, s2
Dim h As Scripting.Dictionary
Set h = New Scripting.Dictionary
While Not GetKeyState(VK_CONTROL) < 0
DoEvents
Call SendMessage(hwnd, WM_GETTEXT, 1024, ByVal pwd1)
s1 = TrimNull(pwd1)
Sleep 20 [no]'50[/no]
Call SendMessage(hwnd, WM_GETTEXT, 1024, ByVal pwd2)
s2 = TrimNull(pwd2)
If s1 = s2 Then
h(Replace(Replace(s1, Chr(10), [no]""[/no]), Chr(13), [no]"<13_10>"[/no])) = 1
End If
Application.Caption = Replace(Replace(s1, Chr(10), [no]""[/no]), Chr(13), [no]"<13_10>"[/no])
Wend
Dim t As String, k
For Each k In h.Keys
t = t & k & Chr(13)
Next k
data2Notepad CStr(t)
End Sub
Public Function TrimNull(startstr As String) As String
Dim pos As Integer
pos = InStr(startstr, Chr$(0))
If pos Then
TrimNull = Left$(startstr, pos - 1)
Exit Function
End If
TrimNull = startstr
End Function