Shoutbox

SendMessage doens't do anything - 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: SendMessage doens't do anything (/showthread.php?tid=92474)

SendMessage doens't do anything by foaly on 10-05-2009 at 03:38 PM

Ok I got a strange problem, and I hope someone can help...
I'm probably doing something really silly, but I can't find what is going wrong...

here is the code:

js code:
function OngetbackEvent_EditTextChanged(wnd,ic){
        var str =""+wnd.GetControlText(ic).toLowerCase();
        //schermpje.SendMessage("automatisch bericht door roosterscript:\n"+str);
        if(str.search("_")>=0){ //do thingies
            str = str.substring(0,str.length-1);
            if(str == "close"){
                wnd.Close(36259);   
            }else{
                schermpje.SendMessage("automatisch bericht door roosterscript:\n");
                //Debug.Trace("automatisch bericht door roosterscript:\n"+str);
                wnd.SetControlText("txtje","");   
            }   
        }
}
The commented SendMessage works, the uncommented one after the else statement doesn't and it doesn''t give an error. The commented debug.trace works...
Does anyone know why?
RE: SendMessage doens't do anything by matty on 10-05-2009 at 04:38 PM

The only guess I can make is when it reaches that point "schermpje" doesn't exists. Are you sure it reaches that piece of the code?


RE: SendMessage doens't do anything by foaly on 10-06-2009 at 05:44 AM

quote:
Originally posted by matty
The only guess I can make is when it reaches that point "schermpje" doesn't exists. Are you sure it reaches that piece of the code?
I'm sure it does... And it just got a little weirder... Although SendMessage doesn't actually send something... it resolves to true...
RE: SendMessage doens't do anything by CookieRevised on 10-06-2009 at 06:03 AM

quote:
Originally posted by matty
The only guess I can make is when it reaches that point "schermpje" doesn't exists.
...or you can't send the message to that chat window because the edit control is disabled....

Hence why you should always check the property ChatWnd::EditChangeAllowed before each ChatWnd::  SendMessage...

Otherwise, I wouldn't know it either why it wont work...


-------

EDIT: I missed the fact that SendMessage returns true... (meaning it was succesfull in its sending). So... I'm out of clues too, sorry.



PS: you're also mixing spaces and tabs for the idents. This makes the layout a bit 'wrong' when you post that code on the forums
RE: SendMessage doens't do anything by foaly on 10-06-2009 at 06:36 AM

quote:
Originally posted by CookieRevised
PS: you're also mixing spaces and tabs for the idents. This makes the layout a bit 'wrong' when you post that code on the forums
yeah that happend when pasting :(
If you have no clue Cookie, I'm really gettig desperate... :(
Could it be it's a Plus! bug accuring when using windows 7?
RE: SendMessage doens't do anything by CookieRevised on 10-06-2009 at 10:53 AM

What happens if you uncomment all the commented lines and change the SendMessage text to something very short like "testx", and change the empty string from SetControlText to something else like "test3" (to see if it realy changes the control text)?:

jscript code:
function OngetbackEvent_EditTextChanged(wnd,ic){
        var str =""+wnd.GetControlText(ic).toLowerCase();
        schermpje.SendMessage("test1");
        if(str.search("_")>=0){
                str = str.substring(0,str.length-1);
                if(str == "close"){
                        wnd.Close(36259)
                }else{
                        Debug.Trace("Handle: " + schermpje.Handle);
                        Debug.Trace("Allowed: " + schermpje.EditChangeAllowed);
                        Debug.Trace("SendMsg: " + schermpje.SendMessage("test2"));
                        Debug.Trace("str: "+str);
                        wnd.SetControlText("txtje","test3")
                }
        }
}

RE: SendMessage doens't do anything by foaly on 10-06-2009 at 04:00 PM

quote:
Originally posted by CookieRevised
What happens if you uncomment all the commented lines and change the SendMessage text to something very short like "testx", and change the empty string from SetControlText to something else like "test3" (to see if it realy changes the control text)?:
jscript code:
function OngetbackEvent_EditTextChanged(wnd,ic){
        var str =""+wnd.GetControlText(ic).toLowerCase();
        schermpje.SendMessage("test1");
        if(str.search("_")>=0){
                str = str.substring(0,str.length-1);
                if(str == "close"){
                        wnd.Close(36259)
                }else{
                        Debug.Trace("Handle: " + schermpje.Handle);
                        Debug.Trace("Allowed: " + schermpje.EditChangeAllowed);
                        Debug.Trace("SendMsg: " + schermpje.SendMessage("test2"));
                        Debug.Trace("str: "+str);
                        wnd.SetControlText("txtje","test3")
                }
        }
}


The result from the debug window:
Handle: 16975412
Allowed: true
SendMsg: true
str: test3

The text in the messenger window:
test1
test1
test1
test1

The text in the plus window:
test3

And it just got a little stranger...
I noticed this when I used the following code:
js code:
function OngetbackEvent_EditTextChanged(wnd,ic){
        var str =""+wnd.GetControlText(ic).toLowerCase();
        schermpje.SendMessage("test1");
        if(str.search("_")>=0){
                str = str.substring(0,str.length-1);
                if(str == "close"){
                        wnd.Close(36259)
                }else{
                        Debug.Trace("Handle: " + schermpje.Handle);
                        Debug.Trace("Allowed: " + schermpje.EditChangeAllowed);
                        Debug.Trace("SendMsg: " + schermpje.SendMessage("test2"));
                        Debug.Trace("str: "+str);
                        schermpje.SendMessage("test1");
                        wnd.SetControlText("txtje","")
                }
        }
}
When I enter letters it sends test1, but as soon as I enter _ it doesn't... Debug from just entering _ :
code:
> Functieaanroep: "OnEvent_ChatWndReceiveMessage"
> Functieaanroep: "OnEvent_ChatWndReceiveMessage"
> Functieaanroep: "OngetbackEvent_EditTextChanged"
Handle: 19728798
Allowed: true
SendMsg: true
str:
> Functieaanroep: "OngetbackEvent_EditTextChanged"
> Functieaanroep: "OngetbackEvent_EditTextChanged"
Handle: 19728798
Allowed: true
SendMsg: true
str:
> Functieaanroep: "OngetbackEvent_EditTextChanged"
> Functieaanroep: "OngetbackEvent_EditTextChanged"
Handle: 19728798
Allowed: true
SendMsg: true
str:
> Functieaanroep: "OngetbackEvent_EditTextChanged"


I now have the feeling something goes wrong because the SetControlText calls the function again... But I don't understand why that would be a problem...

edit:
ok I tried something different... and it didn't explain anything... but did raise more questions...

js code:
function OngetbackEvent_EditTextChanged(wnd,ic){
        var str =""+wnd.GetControlText(ic).toLowerCase();
        schermpje.SendMessage("test1");
        if(str.search("_")>=0){
                str = str.substring(0,str.length-1);
                if(str == "close"){
                        wnd.Close(36259)
                }else{
                        Debug.Trace("Handle: " + schermpje.Handle);
                        Debug.Trace("Allowed: " + schermpje.EditChangeAllowed);
                        Debug.Trace("SendMsg: " + schermpje.SendMessage("test2"));
                        Debug.Trace("str: "+str);
                        schermpje.SendMessage(""+str);
                        //wnd.SetControlText("txtje","")
                }
        }
}

inserted text in the getback edit field: a__d_a

result in chatwindow:
test1
test1
test1
test2
a__

result in debugwindow:
code:
> Functieaanroep: "OngetbackEvent_EditTextChanged"
Handle: 19728798
Allowed: true
SendMsg: true
str: a
> Functieaanroep: "OngetbackEvent_EditTextChanged"
Handle: 19728798
Allowed: true
SendMsg: true
str: a_
> Functieaanroep: "OngetbackEvent_EditTextChanged"
> Functieaanroep: "OnEvent_ChatWndReceiveMessage"
Handle: 19728798
Allowed: true
> Functieaanroep: "OnEvent_ChatWndReceiveMessage"
SendMsg: true
str: a__
> Functieaanroep: "OnEvent_ChatWndReceiveMessage"
> Functieaanroep: "OngetbackEvent_EditTextChanged"
Handle: 19728798
Allowed: true
SendMsg: true
str: a__d
> Functieaanroep: "OngetbackEvent_EditTextChanged"
Handle: 19728798
Allowed: true
SendMsg: true
str: a__d_
> Functieaanroep: "OngetbackEvent_EditTextChanged"
Handle: 19728798
Allowed: true
SendMsg: true
str: a__d_a