Api Send Message - Printable Version
-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Api Send Message (/showthread.php?tid=90411)
Api Send Message by xXDarknessXx on 04-28-2009 at 04:57 PM
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
RE: Api Send Message by matty on 04-28-2009 at 05:26 PM
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:
RE: Api Send Message by xXDarknessXx on 04-28-2009 at 05:54 PM
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.
RE: Api Send Message by matty on 04-28-2009 at 06:03 PM
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.
RE: Api Send Message by xXDarknessXx on 04-28-2009 at 06:14 PM
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
RE: Api Send Message by Mnjul on 04-28-2009 at 06:14 PM
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
jscript code: function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MsgKind){
if(Message=="ok"){
Interop.Call("user32", "PostMessageW", ChatWnd.Handle, 0x0111, 40003, 0);
}
}
RE: Api Send Message by matty on 04-28-2009 at 06:28 PM
Wow I royally screwed up that code... shows what happens when you just write something quickly haha.
RE: Api Send Message by CookieRevised on 04-28-2009 at 10:31 PM
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 )....
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
RE: Api Send Message by xXDarknessXx on 04-29-2009 at 12:49 PM
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.
RE: Api Send Message by matty on 04-29-2009 at 01:21 PM
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);
}
*/
|