quote:
Originally posted by markee
The window does become activated but there is a problem that the chat window object isn't returned and hence why MrT's code is needed unfortunately.
?
The chat window object is returned though, MrT's code is not needed.
ChatWnd = Messenger.OpenChat("smarterchild@hotmail.com");
quote:
Syntax:
[object] OpenChat(
[var] Contact
);
Return Value:
A ChatWnd object if the function succeeds or null if it fails.
However:
quote:
Originally posted by Felu
quote:
Originally posted by bigbob85
But isnt there a way to get the current window handle, send message, then bring the original to the front?
code:
TopWnd = Interop.Call('User32', 'GetForegroundWindow');//Get the Active Window
ChatWnd = Messenger.OpenChat("smarterchild@hotmail.com");//Open the ChatWnd
ChatWnd.SendMessage("Testing");//Send the Message
Interop.Call("User32", "SendMessageW", ChatWnd.Handle, 274, 0xF020, null);//Minimize the ChatWnd
Interop.Call("User32", "BringWindowToTop", TopWnd);//Get the Active Window _BEFORE_ Sending the message on top
When you minimize the chat window again, the window that was on top before will already become the activated/top window again.
So this is not needed either:
TopWnd = Interop.Call('User32', 'GetForegroundWindow');
and
Interop.Call("User32", "BringWindowToTop", TopWnd);
This is all you need:
code:
var ChatWnd = Messenger.OpenChat("smarterchild@hotmail.com");//Open the ChatWnd
ChatWnd.SendMessage("Testing");//Send the Message
Interop.Call("User32", "SendMessageW", ChatWnd.Handle, 274, 0xF020, null);//Minimize the ChatWnd
provided the email is valid and a message can be send, so better add
if (ChatWnd.EditChangeAllowed) {} too...