What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Silent Messages

Pages: (2): « First [ 1 ] 2 » Last »
Silent Messages
Author: Message:
bigbob85
Full Member
***

Avatar
Is Good, Is Bob...

Posts: 128
Reputation: 4
36 / Male / Flag
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
Profile E-Mail PM Web Find Quote Report
Felu
Veteran Member
*****


Posts: 2223
Reputation: 72
29 / Male / Flag
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 [Image: msn_tongue.gif].

Edit: Fixed

This post was edited on 01-16-2007 at 02:12 PM by Felu.
01-15-2007 10:48 AM
Profile E-Mail PM Web Find Quote Report
bigbob85
Full Member
***

Avatar
Is Good, Is Bob...

Posts: 128
Reputation: 4
36 / Male / Flag
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
Profile E-Mail PM Web Find Quote Report
Plik
Veteran Member
*****

Avatar

Posts: 1489
Reputation: 46
34 / Male / –
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
Profile PM Find Quote Report
bigbob85
Full Member
***

Avatar
Is Good, Is Bob...

Posts: 128
Reputation: 4
36 / Male / Flag
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 :P

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
Profile E-Mail PM Web Find Quote Report
Felu
Veteran Member
*****


Posts: 2223
Reputation: 72
29 / Male / Flag
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
Profile E-Mail PM Web Find Quote Report
MrT
Junior Member
**

Coding For Fun

Posts: 62
35 / Male / Flag
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 }

:D

->    sendmsg("smarterchild@hotmail.com","hi")
01-17-2007 04:26 PM
Profile E-Mail PM Web Find Quote Report
Eljay
Elite Member
*****

Avatar
:O

Posts: 2949
Reputation: 77
– / Male / –
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 }

:D

->    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
Profile PM Find Quote Report
markee
Veteran Member
*****

Avatar

Posts: 1621
Reputation: 50
35 / Male / Flag
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 }

:D

->    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.
[Image: markee.png]
01-18-2007 12:26 AM
Profile PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
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
Profile PM Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On