Shoutbox

Disable access to parent chat window when child xml window open - 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: Disable access to parent chat window when child xml window open (/showthread.php?tid=69194)

Disable access to parent chat window when child xml window open by the andyman on 12-05-2006 at 10:27 PM

Is it possible to make it so that a window that is brought up by a script has to be on top of the conversation window that it was brought up by. I.e. the script/new xml window has to closed or another action taken in it which closes it before anything can be done or clicked in the parent (conversation) window.

I have tried looking for info in the script docs for this with no luck. I presume it will probably be some tag or property I need to add to the xml of the new window.

I hope someone understands what I mean and can help. Thanks.


EDIT: I am also having trouble closing the new xml window when one of the buttons is pressed, in the js I'm telling it to Wnd.Close(1); when either is pressed, is this right?


RE: Disable access to parent chat window when child xml window open by Matti on 12-06-2006 at 03:23 PM

quote:
Originally posted by MSDN
The EnableWindow function enables or disables mouse and keyboard input to the specified window or control. When input is disabled, the window does not receive input such as mouse clicks and key presses. When input is enabled, the window receives all input.

Syntax:
code:
    BOOL EnableWindow(     

        HWND hWnd,
        BOOL bEnable
    );
Parameters:
  • hWnd
    [in] Handle to the window to be enabled or disabled.
  • bEnable
    [in] Specifies whether to enable or disable the window. If this parameter is TRUE, the window is enabled. If the parameter is FALSE, the window is disabled.

So, a good way to do it would be:
code:
Interop.Call("user32.dll", "EnableWindow", Wnd.Handle, false);
where Wnd is a valid ChatWnd object. ;)

As for your closing problem, make sure you call it right:
code:
function OnWndEvent_CtrlClicked(Wnd, Id) {
   if(Id == "BtnOk") {
      Wnd.Close(0); //The number doesn't really matter, but it's more common to just set it to zero
   }
}
Maybe it would be helpful if you post the code snippet where you call the Close function. :)
RE: Disable access to parent chat window when child xml window open by the andyman on 12-06-2006 at 04:54 PM

Thanks :), I'll have a play around with the info you've given me


The window disable works great (although if you go off the windows and then back to the conversation window the xml window isn't on top) but thanks anyway, I'm sure it's fine as it is (Y)

As for the closing problem this is basically what I've got:
code:
    function OnconfirmEvent_CtrlClicked(Wnd, Id){
    if(Id == "BtnYes"){
        // do other stuff I want it to do, then:
        return Message;
        Wnd.Close(0);
        Interop.Call("user32.dll", "EnableWindow", ChatWnd.Handle, true);
    }else{
        Wnd.Close(0);
        Interop.Call("user32.dll", "EnableWindow", ChatWnd.Handle, true);
        // do other stuff I want it to do, then:
        return false;
    }
}

RE: RE: Disable access to parent chat window when child xml window open by J-Thread on 12-06-2006 at 10:29 PM

quote:
Originally posted by the andyman
code:
        return Message;
        Wnd.Close(0);
        Interop.Call("user32.dll", "EnableWindow", ChatWnd.Handle, true);


Code after the return will not be executed. Make that:
code:
        Wnd.Close(0);
        Interop.Call("user32.dll", "EnableWindow", ChatWnd.Handle, true);
        return Message;


RE: Disable access to parent chat window when child xml window open by the andyman on 12-07-2006 at 06:17 PM

Thanks, but the window is still not closing. I can't see any problem with it either :@


RE: RE: Disable access to parent chat window when child xml window open by Matti on 12-07-2006 at 07:39 PM

code:
    function OnconfirmEvent_CtrlClicked(Wnd, Id){
    if(Id == "BtnYes"){
        // do other stuff I want it to do, then:
        return Message;
        Wnd.Close(0);
        Interop.Call("user32.dll", "EnableWindow", ChatWnd.Handle, true);
    }else{
        Wnd.Close(0);
        Interop.Call("user32.dll", "EnableWindow", ChatWnd.Handle, true);
        // do other stuff I want it to do, then:
        return false;
    }
}
Why do you want to return something anyway? The scripting documentation says it doesn't need a return value for the OnWndEvent_CtrlClicked event, so why would you? :P
Other than that, I don't actually see the problem... but where did you define that ChatWnd variable? ^o)

And also, do you have anything in your debugging window?
RE: RE: RE: Disable access to parent chat window when child xml window open by the andyman on 12-07-2006 at 08:53 PM

quote:
Originally posted by Mattike
Why do you want to return something anyway? The scripting documentation says it doesn't need a return value for the OnWndEvent_CtrlClicked event, so why would you? :P
because if one of the options is clicked in the xml windows then the message is send otherwise it isn't

quote:
Originally posted by Mattike
where did you define that ChatWnd variable? ^o)
in a function OnEvent_ChatWndSendMessage(ChatWnd, Message){ before the code I posted above

quote:
Originally posted by Mattike
And also, do you have anything in your debugging window?
I'm pretty sure I didn't before but now it does say that 'ChatWnd' is undefined, but only on the lines where I re-enable it :S. By the looks of it if I get that bit fixed then the whole thing should work (yn).
RE: Disable access to parent chat window when child xml window open by Spunky on 12-07-2006 at 09:40 PM

quote:
Originally posted by the andyman
I'm pretty sure I didn't before but now it does say that 'ChatWnd' is undefined, but only on the lines where I re-enable it . By the looks of it if I get that bit fixed then the whole thing should work .

Remember to store the ChatWnd in a global variable (defined outside of a function, if you haven't already) else when you enter a different function it won't exist

RE: RE: Disable access to parent chat window when child xml window open by the andyman on 12-08-2006 at 05:54 PM

quote:
Originally posted by SpunkyLoveMuff
Remember to store the ChatWnd in a global variable (defined outside of a function, if you haven't already) else when you enter a different function it won't exist
yeah I worked that out last night but thanks anyway

It does seem to be working properly now except only when I use the enter button to send a message, not the "Send" button :(

Also, is there any way to remove the text that is left in the text box in the conversation window?
RE: Disable access to parent chat window when child xml window open by CookieRevised on 12-08-2006 at 07:07 PM

quote:
Originally posted by the andyman
yeah I worked that out last night but thanks anyway

It does seem to be working properly now except only when I use the enter button to send a message, not the "Send" button :(

You better post the entire script so all this can be checked upon properly. Because it sounds like you're doing some wrong thingie somewhere, maybe...

Also, what you actually want is making a dialog "modal". This means it will recieve all input until it closes and only then the "parent" window will be able to recieve input again. I doubt the EnableWindow API is the correct thing to use, that is: the only thing to use...

But I may be wrong in this (need todo some looking up).

quote:
Originally posted by the andyman
Also, is there any way to remove the text that is left in the text box in the conversation window?
Return an empty string from the ChatWndSendMessage event.

RE: RE: Disable access to parent chat window when child xml window open by the andyman on 12-09-2006 at 05:22 PM

Ok here's a beta version of the script (still with bugs). If anyone can figure out what's wrong I will be very grateful.

You may see the script as pretty pointless but in the future there will be extended functionality etc

quote:
Originally posted by CookieRevised
quote:
Originally posted by the andyman
Also, is there any way to remove the text that is left in the text box in the conversation window?
Return an empty string from the ChatWndSendMessage event.
that doesn't seem to be working :|
RE: RE: RE: Disable access to parent chat window when child xml window open by pollolibredegrasa on 12-09-2006 at 05:30 PM

I get a "not a valid script file" error when trying to import. :s


Edit: changed the first line to <?xml version="1.0"?>, repackaged and it worked.

Edit 2: After importing, I get "Error: Invalid root in registry key". This can be solved by checking if the user is signed in in the OnEvent_Initialize function, and then if they are call the OnEvent_Signin function passing Messenger.MyEmail. This way the user does not have to re-sign in for the script to work.

Also, one way to solve your removing the text from the text box problem would be to use ChatWnd.EditText_SetCurSel - look in the scripting doc for more info ;)



RE: Disable access to parent chat window when child xml window open by the andyman on 12-09-2006 at 06:51 PM

Thanks, I think I've fixed all the n00bish errors you pointed out :), and I got the EditText_SetCurSel working. Here's an updated version of the script...


RE: RE: RE: Disable access to parent chat window when child xml window open by the andyman on 12-10-2006 at 07:04 PM

quote:
Originally posted by the andyman
It does seem to be working properly now except only when I use the enter button to send a message, not the "Send" button
is anyone getting this bug with the most recent version (posted directly above)?
RE: RE: RE: RE: Disable access to parent chat window when child xml window open by pollolibredegrasa on 12-10-2006 at 07:28 PM

quote:
Originally posted by the andyman
quote:
Originally posted by the andyman
It does seem to be working properly now except only when I use the enter button to send a message, not the "Send" button
is anyone getting this bug with the most recent version (posted directly above)?


I get the window whether I press enter or use the send button, and it works either way.

Still getting the registry error though when I use an account who's settings are not saved.
RE: RE: RE: RE: RE: Disable access to parent chat window when child xml window open by the andyman on 12-10-2006 at 09:51 PM

quote:
Originally posted by fatfreechicken
Still getting the registry error though when I use an account who's settings are not saved.
Hmm, thanks for telling me - I'll have (another) look now.
RE: RE: RE: RE: RE: RE: Disable access to parent chat window when child xml window op by the andyman on 12-11-2006 at 05:58 PM

quote:
Originally posted by the andyman
quote:
Originally posted by fatfreechicken
Still getting the registry error though when I use an account who's settings are not saved.
Hmm, thanks for telling me - I'll have (another) look now.
I'm pretty sure it should be working, and seems to have worked for other's that have tried it. Here's the code I'm currently using to check for the registry value:
code:
var Shell = new ActiveXObject("WScript.Shell");
function OnEvent_Initialize(MessengerStart){
try{
    var echeck = Messenger.MyEmail;
}catch(e){
    var echeck = "null";
}
if(echeck=="null"){
    function OnEvent_Signin(Email){
        try{
            Shell.RegRead(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\enabled");
        }catch(e){
            Shell.RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\enabled","true");
        }
    }
}else{
    try{
        Shell.RegRead(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\enabled");
    }catch(e){
        Shell.RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\enabled","true");
    }
}
}

RE: Disable access to parent chat window when child xml window open by the andyman on 12-11-2006 at 06:30 PM

Sorry for all the double postings. Here's a new version which includes an option to only ask you to confirm once when you are first appear offline.