Windowless Rich Edit Text Box
Hey...I'm in the process of making an WLM add on which will run like an MSN bot. It will have all the commands that an MSN bot will have but the user will also be able to talk to the people on their contact list.
So far i have managed to hook the MSN and add my own sub menu. And i have managed to hook winsock to detect when a message is received. But i'm having a problem trying to send a message. I don't want to use the API because it uses the SendKeys function which is a bit tacky.
I know that the input text box is a windowless rich edit text box and i was wondering how i can actually hook it and input text to it. If thats not possible could someone give me an example of how i could do the same thing with Active Accessibility?
Thanks in advanced.
Re: Windowless Rich Edit Text Box
there is a meesenger client example in the codebank section.
might be worth a peek...
Re: Windowless Rich Edit Text Box
You can't hook windowless controls since they are not windows and don't have a message queue.
All the messages are handled by the container so you'll have to hook the containing window.
Re: Windowless Rich Edit Text Box
Hey moeur, by containing window i take it you mean the whole conversation window? If so i have managed to hook that already and add a sub menu. But i am unsure of how to send Text to the input box? Is it possible you could point me in the right direction? Thanks.
Re: Windowless Rich Edit Text Box
Wouldn't you just need to spy what messages are going out when you write a message? One of them ought to be the message that contains the outgoing message (a pointer to string or a pointer to structure that contains pointer to string).
Re: Windowless Rich Edit Text Box
I dont want to detect when i write a message. I want to make my program automatically respond if someone types !help for example.
Re: Windowless Rich Edit Text Box
I didn't mean that. I meant that by sniffing how the MSN window works you will know what message to send and where to send if such message is outputted from the window elsewhere; and then code based on that. So you don't need to access the richtextbox at all to send text.
Re: Windowless Rich Edit Text Box
How would i sniff how the MSN window works?
I tried sniffing the packets but they dont seem to have a pattern:
When i receive a message the packet is this:
Code:
MSG [email protected] -={TWM}=-_Jaffa_Cake 133
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-MMS-IM-Format: FN=Microsoft%20Sans%20Serif; EF=; CO=0; CS=0; PF=22
?
The question mark being the message i receive and the email address being who i receive it from. Thats completly logical.
But, when i send a message the packet is:
Code:
MSG 177 N 145
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-MMS-IM-Format: FN=MS%20Shell%20Dlg; EF=; CO=0; CS=0; PF=0
Hey
Now...the numbers in the MSG section always change even if it is to the same person so how does it know where its going? :s
However, i'm hoping your suggesytion of sniffing the window will tell me exactly what i need to do? It's just i never heard of sniffing another applications actions? :S
Re: Windowless Rich Edit Text Box
Well, I once sniffed how mIRC worked, although differently: I just made the program connect to my own "proxy" program that displayed all the messages mIRC sent and received. I did this to know how the most popular program does traffic handling so I could duplicate the behaviour in my own program to ensure compatibility with most IRC servers.
Anyways, that was just an example. By sniffing what the other program does you can duplicate the behavior. However, I got another suggestion: take a look at MSN client done by Wokawidget, Badger Messenger. I believe you'll find the information you need by taking a look at how that program works.
Re: Windowless Rich Edit Text Box
I don't know how you are going to communicate with the windowless control from outside the program that created the control. Certainly not from VB.
Windowless controls communicate with their container using a two-way system of event firing and exposing methods and properties to the container.
You'll have to investigate the MFC interfaces involved to see if this system can be tapped into via C++. Look up:
COleControl Class
Windowless Controls
IOleInPlaceObjectWindowless
1 Attachment(s)
Re: Windowless Rich Edit Text Box
I have found an example on the net which uses Active Accessibility. But at the moment i keep getting the error Object Required and im not sure why.
I would appreciate it if someone could have at look at it. Thanks
Re: Windowless Rich Edit Text Box
On what line do you get the error?
Check Project/References and make sure you have Accesibility checked
Re: Windowless Rich Edit Text Box
I found a problem in the code. Change this routine
VB Code:
Private Sub cmdTest_Click()
If lstContacts.SelCount = 0 Then Exit Sub
If lstContacts.Text = "<All>" Then
Else
Dim hwnd As Long
Dim hwnd2 As Long
hwnd = Val(Left(lstContacts.Text, InStr(lstContacts.Text, " - ") - 1))
hwnd2 = FindWindowEx(hwnd, 0, "BrowserFrameGripperClass", vbNullString)
Dim lngTMP As IAccessible
Call AccessibleObjectFromWindow(hwnd2, OBJID_CLIENT, IID_IAccessible, lngTMP)
If lngTMP Is Nothing Then
Else
Dim iTMP As IAccessible
Dim lngTMP2 As Long
Set iTMP = lngTMP.accParent
Dim lngCount As Long
lngCount = iTMP.accChildCount
Dim accChildren() As Variant
[hl] ReDim accChildren(1 To lngCount)
Call AccessibleChildren(iTMP, 0, lngCount, accChildren(1), lngTMP2)
Dim lngCount2 As Long
For lngCount2 = 1 To lngCount[/hl]
lstIObjects.AddItem accChildren(lngCount2).accName(CHILDID_SELF) & ":" & accChildren(lngCount2).accValue(CHILDID_SELF)
If accChildren(lngCount2).accName(CHILDID_SELF) = "Input" Then
accChildren(lngCount2).accValue(CHILDID_SELF) = "You see this so you know it's working!"
End If
Next
End If
End If
End Sub
Re: Windowless Rich Edit Text Box
Thanks, I really appreciate it. I'll let you know how i get on later :)