If the cursor is active, you could just try using SendKeys sort of thing, but thats a bit messy. An example is:
Matty's reply to hWnd of IMWindowClass chat input box
I dont think you can directly use
FindWindow and
FindWindowEx to retrieve the handle, as Messenger windows are all wrapped in a DirectUIHWND or something.
I *think* you can retireve it using Active Accesability, but if all want the handle for is to set the text, then it will definatley work, you can see this example in Visual Basic:
Matty's reply to Active Accessibility for incoming messages