Silent Messages |
Author: |
Message: |
bigbob85
Full Member
Is Good, Is Bob...
Posts: 128 Reputation: 4
37 / /
Joined: Jul 2003
|
O.P. Silent Messages
Hey,
Im wondering if anyone would have any ideas how to send a message to a chat window silently (not really silently), so you don't loose focus from the current window.
Is it even possible?
|
|
01-15-2007 10:06 AM |
|
|
Felu
Veteran Member
Posts: 2223 Reputation: 72
30 / /
Joined: Apr 2006
Status: Away
|
RE: Silent Messages
code: 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
I guess thats what you want .
Edit: Fixed
This post was edited on 01-16-2007 at 02:12 PM by Felu.
|
|
01-15-2007 10:48 AM |
|
|
bigbob85
Full Member
Is Good, Is Bob...
Posts: 128 Reputation: 4
37 / /
Joined: Jul 2003
|
O.P. RE: Silent Messages
Works well... Cept..
Bad calling convention detected for "SendMessageW" in "User32". The function must be declared with __stdcall and called with the appropriate number of parameter.
In the debug window...
* bigbob85 googles
|
|
01-15-2007 11:11 AM |
|
|
Plik
Veteran Member
Posts: 1489 Reputation: 46
35 / / –
Joined: Jun 2004
|
RE: Silent Messages
Change it to
code: Interop.Call("User32", "SendMessageW", ChatWnd.Handle, 274, 0xF020, 0);//Minimize the ChatWnd
Because SendMessage wants 4 parameters, but that last (lParam) isn't used when you minimize
|
|
01-15-2007 11:19 AM |
|
|
bigbob85
Full Member
Is Good, Is Bob...
Posts: 128 Reputation: 4
37 / /
Joined: Jul 2003
|
O.P. RE: Silent Messages
Felu told me to change it to true, and it works. But I'll use 0, it seems more... correct
But isnt there a way to get the current window handle, send message, then bring the original to the front?
code: var CurWindow = Interop.Allocate(32);
Interop.Call('User32', 'GetTopWindow', CurWindow);
// Send Message
Interop.Call("User32", "BringWindowToTop", CurWindow);
And
code: //var CurWindow = Interop.Allocate(32);
var CurWindow;
Interop.Call('User32', 'GetTopWindow', CurWindow);
//Debug.Trace(CurWindow);
//Debug.Trace(CurWindow.Handle);
Contact.SendMessage("/np");
Interop.Call('User32','ShowWindow', CurWindow, SW_SHOW);
Not sure if I'm ment to read this differently, or define CurWindow differently...
SW_SHOW is definded aswell. (its 5)
code: var CurWindow = Interop.Allocate((255 *2) +2);
Interop.Call('User32', 'GetTopWindow', CurWindow);
ChatWnd.SendMessage("/np");
Interop.Call('User32','ShowWindow', CurWindow.ReadString(0), SW_SHOW);
Shouldnt this one work?
This post was edited on 01-16-2007 at 10:26 AM by bigbob85.
|
|
01-16-2007 10:01 AM |
|
|
Felu
Veteran Member
Posts: 2223 Reputation: 72
30 / /
Joined: Apr 2006
Status: Away
|
RE: Silent Messages
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
This post was edited on 01-16-2007 at 02:12 PM by Felu.
|
|
01-16-2007 02:09 PM |
|
|
MrT
Junior Member
Coding For Fun
Posts: 62
35 / /
Joined: Jul 2006
|
RE: Silent Messages
code:
function sendmsg(kime,msj) {
for(var e = new Enumerator(Messenger.CurrentChats); !e.atEnd(); e.moveNext())
{
var curWnd = e.item();
for(var f = new Enumerator(curWnd.Contacts); !f.atEnd(); f.moveNext())
{
if(f.item().Email == kime)
{
varmi = 1;
ChatWnd = curWnd;
break;
}
else {
if(varmi == null) {
varmi = 0;
}
}
}
}
if(varmi == 1) {
ChatWnd.SendMessage(msj);
}
if(varmi == 0) {
kisi = Messenger.OpenChat(kime);
kisi.SendMessage(msj);
}
}
if (you have a chat window with your contact)
{ send message }
else
{ open chat window
send message }
-> sendmsg("smarterchild@hotmail.com","hi")
|
|
01-17-2007 04:26 PM |
|
|
Eljay
Elite Member
:O
Posts: 2949 Reputation: 77
– / / –
Joined: May 2004
|
RE: Silent Messages
quote: Originally posted by MrT
...
if (you have a chat window with your contact)
{ send message }
else
{ open chat window
send message }
-> sendmsg("smarterchild@hotmail.com","hi")
That is what OpenChat already does though...
quote: Originally posted by Scripting Documentation
The Messenger:: OpenChat function opens a chat window with the specified contact. If a chat window with this contact is already opened, the window is activated.
This post was edited on 01-17-2007 at 04:29 PM by Eljay.
|
|
01-17-2007 04:29 PM |
|
|
markee
Veteran Member
Posts: 1622 Reputation: 50
36 / /
Joined: Jan 2006
|
RE: RE: Silent Messages
quote: Originally posted by Eljay
quote: Originally posted by MrT
...
if (you have a chat window with your contact)
{ send message }
else
{ open chat window
send message }
-> sendmsg("smarterchild@hotmail.com","hi")
That is what OpenChat already does though...
quote: Originally posted by Scripting Documentation
The Messenger:: OpenChat function opens a chat window with the specified contact. If a chat window with this contact is already opened, the window is activated.
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.
|
|
01-18-2007 12:26 AM |
|
|
CookieRevised
Elite Member
Posts: 15517 Reputation: 173
– / /
Joined: Jul 2003
Status: Away
|
RE: RE: RE: Silent Messages
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...
This post was edited on 01-18-2007 at 04:21 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
|
|
01-18-2007 03:53 AM |
|
|
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|