- This topic has 3 replies, 3 voices, and was last updated 16 years ago by Departure.
-
AuthorPosts
-
November 25, 2007 at 7:29 pm #190809wazzzupMember
i need help update trivia bot from 9.1 to 9.2 thanks 😀
November 26, 2007 at 4:10 am #190812DepartureMemberput the source snippet for 9.1 and ill modify it for you to work with 9.2 and future version + older versions. I have found a new way to do this using EnumChildWindows instead of the standard findwindowex, this method should have been used first from what read, because GETCHILD , HWNDNEXT is unstable used in a loop.
here is an example:
Private Sub Form_Load()
Dim hWndForm As Long
'get the form handle
hWndForm = FindWindow(vbNullString, "")
'enumerate child windows of the window
If hWndForm 0 Then EnumChildWindows hWndForm, AddressOf EnumChildProc, ByVal 0&
End Sub
'=================
'In a standard module
Option Explicit
Public Declare Function EnumChildWindows Lib "user32" _
(ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" _
(ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
'call back function
Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
'assuming it is a Richedit box, other wise change the class name
If GetClsName(hwnd) = "RichEdit20A" Then
GlobalRichEditString = hwnd
End If
'continue enumeration
EnumChildProc = 1
End Function
'gets the class name
Public Function GetClsName(ByVal hwnd As Long) As String
Dim lpClassName As String
Dim RetVal As Long
lpClassName = Space(256)
'retrieve the class name
RetVal = GetClassName(hwnd, lpClassName, 256)
'Show the classname
GetClsName = Left$(lpClassName, RetVal)
End Function
Only thing I did’nt do was add a global string but just add that as “GlobalRichEditString” then when sending text ect… just use that for the handel of richedit box. And also this executes on form load so you could add this to a button or something instead of when the form loads, I just put loads for when I embed the form into paltalk (which is not here)
November 26, 2007 at 5:51 am #190811GhostMemberWrong section, moved to Programming Help.
November 30, 2007 at 6:04 pm #190810wazzzupMemberThanks Departure
-
AuthorPosts
Related
- You must be logged in to reply to this topic.