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

Api Send Message
Author: Message:
xXDarknessXx
New Member
*


Posts: 8
33 / Male / Flag
Joined: Apr 2009
O.P. Huh?  Api Send Message
Hey i am looking for an API function thing that will block/unblock a certain contact and an API that sends a message to a certain contact.

Please don't say it cant be done[at least not for the send message] because that has been done its in the Linked chats script I just don't see how it works or how i could use it.

I am trying to use API because as far as i know i cant use ChatWnd to read what I send in one chat and send it in another as well.

A more detailed description I have made a chat window open up when you open a chat with a blocked person, say their email is "email@host.com". It will automatically open a chat with a contact called emailhost.com@xXDarknessxx.chat.com[which does not exist], now what I am looking for is when i send a message to emailhost.com@xXDarknessxx.chat.com it will unblock email@host.com, send them the same message i send the emailhost.com@xXDarknessxx.chat.com and the reblock email@host.com.

I cannot find a way to send a message to a chat window I didn't send the message in or how to block/unblock a contact unless Im in their chat window.

Thank you in advance
[Image: 1714-1.png]
04-28-2009 04:57 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Api Send Message
js code:
var oChatWnds = {};

function OnEvent_ChatWndCreated(oChatWnd) {
    if (oChatWnd.Contacts.Count !== 1) return;
    for (var oContact = new Enumerator(oChatWnd.Contacts); !oContact.atEnd(); oContact.moveNext()) {
        if (oContact.item().Blocked === true) {
            var tChatWnd = Messenger.OpenChat(oContact.item().Email.replace('@', '')+'@xXDarknessxx.chat.com')
            oChatWnds[tChatWnd.Handle] = {};
                oChatWnds[tChatWnd.Handle].ChatWnd = tChatWnd;
                oChatWnds[tChatWnd.Handle].Email = oContact.item().Email;
            Interop.Call('user32', 'SendMessageW', oChatWnd.Handle, 0x10 /* WM_CLOSE */,0,0);
        }
    }
}

function OnEvent_ChatWndSendMessage(oChatWnd, sMessage) {
    if (oChatWnd.Contacts.Count !== 1) return;
    for (var oContact = new Enumerator(oChatWnd.Contacts); !oContact.atEnd(); oContact.moveNext()) {
        if (oContact.item().Email.indexOf('@xXDarknessxx.chat.com') !== -1) {
            oContact.item().Blocked = false;
            var tChatWnd = Messenger.OpenChat(oChatWnds[oChatWnd.Handle].Email)
            tChatWnd.SendMessage(sMessage)
            oContact.item().Blocked = true;
        }
    }
}

function OnEvent_ChatWndDestroyed(oChatWnd) {
    delete oChatWnds[oChatWnd.Handle];
}

Something along those lines:
04-28-2009 05:26 PM
Profile E-Mail PM Find Quote Report
xXDarknessXx
New Member
*


Posts: 8
33 / Male / Flag
Joined: Apr 2009
O.P. RE: Api Send Message
Sorry I tried this but no success
crashed MSN every time until i commented out the "Interop.Call" line but now its doing somthin opposite to what I want, either I didn't explain or a muck up in code I don't know.
[Image: 1714-1.png]
04-28-2009 05:54 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Api Send Message
quote:
Originally posted by xXDarknessXx
Sorry I tried this but no success
crashed MSN every time until i commented out the "Interop.Call" line but now its doing somthin opposite to what I want, either I didn't explain or a muck up in code I don't know.
Well what is it doing? I didn't test it as I am at work.
04-28-2009 06:03 PM
Profile E-Mail PM Find Quote Report
xXDarknessXx
New Member
*


Posts: 8
33 / Male / Flag
Joined: Apr 2009
O.P. RE: Api Send Message
It blocked the bothotmail@xxdarknessxx.chat.com chat then just moved what i said into the original chat window(bot@hotmail.com)

Sorry if i didn't make it clear enough but i want the "@xxdarknessxx.chat.com" chat window to be where i do all my typing and when I press enter it unblocks the original chat, sends the message, then reblocks them

I'm sorry i don't really get API but I found this in another script
code:
Interop.Call("user32", "SendMessageW", wnd.Handle, 0x80, 0, 0);
would I be able to use this? if so could you explain how please
[Image: 1714-1.png]
04-28-2009 06:14 PM
Profile E-Mail PM Find Quote Report
Mnjul
forum super mod
******

Avatar
plz wub me

Posts: 5396
Reputation: 58
– / Other / Flag
Joined: Nov 2002
Status: Away
RE: Api Send Message
quote:
Originally posted by Mnjul
Try PostMessage instead of SendMessage? Perhaps calling SendMessage within a Plus! event handler can cause unexpected troubles.

quote:
Originally posted by Mnjul
Just replace the SendMessage with PostMessage in your crash code:p

jscript code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MsgKind){
if(Message=="ok"){
Interop.Call("user32", "PostMessageW", ChatWnd.Handle, 0x0111, 40003, 0);
}
}

04-28-2009 06:14 PM
Profile PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Api Send Message
Wow I royally screwed up that code... shows what happens when you just write something quickly haha.
04-28-2009 06:28 PM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Api Send Message
Maybe I'm completely misunderstanding what you actually want xXDarknessXx, but from what I understand you misunderstand what an API is... (can you still follow :p)....

There is no Windows API to send a message to a chat window and/or block a contact. An API is a special procedure build into Windows which does some low-level stuff, no matter what kind of program the application is.

The "SendMessage" Windows API, which you can call and execute with a Interop.Call() instruction in Plus! scripting, has got absolutely nothing to do with Instant Messaging. It is just a name of a very common used internal Windows procedure to send a numerical command to a specific window. It is not meant to send text to a IM conversation window. It is not because the name of that special internal Windows procedure has "Message" in its name that it got something todo with instant messaging.

To block/unblock contacts you must use an instruction in Plus! scripting. The same for sending text to a conversation window. You don't need any Windows API for these things. For blocking a contact you use the Plus! scripting instruction:
  [contact object].Blocked = true or false
For sending a message to a chatwindow:
  [chatwindow object].SendMessage(text)

See the Official Scripting Help (or press F1 while in the scripting editor) for information about these instructions and how to use them.


The "SendMessage" Windows API used by Matty (which should have been the "PostMessage" API) in his example script simply sends a special instruction to a window to instruct it to close.

Info about what Windows APIs are can be found here: http://en.wikipedia.org/wiki/Windows_API

This post was edited on 04-28-2009 at 10:36 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
04-28-2009 10:31 PM
Profile PM Find Quote Report
xXDarknessXx
New Member
*


Posts: 8
33 / Male / Flag
Joined: Apr 2009
O.P. RE: Api Send Message
omg that's embarrassing lol sorry guys and thanks CookieRevised =]
umm could you please explain how i would use this =P

  [contact object].Blocked = true or false
  [chatwindow object].SendMessage(text)

I tried setting Contact as their email and then doing
Contact.Blocked = false but it says type mismatch, if you could help me with that id be very grateful.
[Image: 1714-1.png]
04-29-2009 12:49 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Api Send Message
The contact object is only exposed by enumerating the ChatWnd.Contacts property or the Messenger.MyContacts property.

js code:
function OnEvent_ChatWndCreated(oChatWnd) {
    for (var oContact = new Enumerator(oChatWnd.Contacts); !oContact.atEnd(); oContact.moveNext()) {
        Debug.Trace(oContact.item().Email+' : '+oContact.item().Blocked);
    }
}

/*

    for (var oContact = new Enumerator(Messenger.MyContacts); !oContact.atEnd(); oContact.moveNext()) {
        Debug.Trace(oContact.item().Email+' : '+oContact.item().Blocked);
    }

*/
04-29-2009 01:21 PM
Profile E-Mail PM Find Quote Report
« 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