What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Help with SendMessage()

Help with SendMessage()
Author: Message:
Coso
New Member
*


Posts: 3
35 / Male / Flag
Joined: Jul 2010
O.P. Help with SendMessage()
First of all I'm a n00b at scripting.
And my problem is this:
The script has a menu and when i click it, it creates a window with a button.. that works fine..

and when I push the button it should send a message in the chat window I clicked the menu...
But I don't know how to deffine the ChatWnd so I always get the same error.

'ChatWnd' is undefined
error code: -2146823279


There is no event in the chat window I what to send the message.

function OnCodedWndEvent_CtrlClicked(Wnd1, ControlId)
{
    if(ControlId == "BtnSnd")
        {

        ChatWin.SendMessage("Message");
        }


Is there a way to deffine the ChatWnd without having a event like OnEvent_ChatWndReceiveMessage(ChatWnd, Name, message, msgkind) so the script could use it later?
Lets say just by clicking the menu of the script in the chat window...?
07-29-2010 08:27 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Help with SendMessage()
The reason it isn't making sense is because you are not globally defining the Chat Window object. You could do this by putting var objChatWnd; at the top of your script then in your OnEvent_MenuClicked you would assign objChatWnd = pChatWnd. The problem then becomes how do you support multiple windows. Well you would do that with the following code. Let me know if this doesn't make sense.

js code:
// Object container
var oChatWnds = {};

// We clicked a menu item, let us make sure it is from the chat window
function OnEvent_MenuClicked(sMenuItemId, nLocation, pChatWnd) {
    if (nLocation === MENULOC_CHATWND) {
        // Create the window
        var tmpWindow = MsgPlus.CreateWnd('TestXmlFile.xml', 'TestWindow');
        // Store the Chat Window object in a container
        oChatWnds[tmpWindow.Handle] = pChatWnd;
    }
}

// We pushed a button
function OnTestWindowEvent_CtrlClicked(pPlusWnd, sControlId) {
    // Make sure we are allowed to send a message
    // and that the contact isn't offline or blocked
    if (oChatWnds[pPlusWnd.Handle].EditChangeAllowed === true)
        // Send the message
        oChatWnds[pPlusWnd.Handle].SendMessage('This message was sent from clicking a control in a window.');
}

// Our window is closed we need to remove
// the association in the object container
function OnTestWindowEvent_Destroyed(pPlusWnd) {
    delete oChatWnds[pPlusWnd.Handle];
}

function OnEvent_ChatWndDestroyed(pChatWnd) {
    for (var i in oChatWnds) {
        if (oChatWnds[i].Handle === pChatWnd.Handle) {
            // Close the original window
            Interop.Call('user32', 'SendMessageW', i, 0x10, 0, 0);
            // Delete the object from the container
            delete oChatWnds[i];
        }
    }
}

This post was edited on 07-30-2010 at 02:53 PM by matty.
07-30-2010 01:33 PM
Profile E-Mail PM Find Quote Report
Coso
New Member
*


Posts: 3
35 / Male / Flag
Joined: Jul 2010
O.P. RE: RE: Help with SendMessage()
For me it's not working... but at least it's a different error this time :P

quote:
Object doesn't support this property or method (code: -2146827850)
Function OnCodedWndEvent_CtrlClicked returned an error. Code: -2147352567


The error is on sendmessage line:
js code:
oChatWnds[pPlusWnd.Handle].SendMessage = 'This message was sent from clicking a control in a window.';

This post was edited on 07-30-2010 at 02:48 PM by Coso.
07-30-2010 02:46 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Help with SendMessage()
quote:
Originally posted by Coso
For me it's not working... but at least it's a different error this time :P
Can you post all of your code please.

Also please use the following tags [code=js][/code].

Corrected it. Should be:
js code:
oChatWnds[pPlusWnd.Handle].SendMessage('This message was sent from clicking a control in a window.');

This post was edited on 07-30-2010 at 02:49 PM by matty.
07-30-2010 02:48 PM
Profile E-Mail PM Find Quote Report
Coso
New Member
*


Posts: 3
35 / Male / Flag
Joined: Jul 2010
O.P. RE: RE: Help with SendMessage()
LoL
I didn't see that...


Thank you!
Now it works perfectly... :)
07-30-2010 03:06 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Help with SendMessage()
Glad it works. If you need anything else you know where to find us.
07-30-2010 04:09 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