Shoutbox

JIT - Debug popups - 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: JIT - Debug popups (/showthread.php?tid=94307)

JIT - Debug popups by SiliconShadow on 04-05-2010 at 07:59 PM

MY JIT (Just in time debugger) Kicks in every time I close msn with MsgPlus installed on the Wnd.Close() line, the debugger says Wnd is undefined.

code:
function OnEvent_Uninitialize(MessengerExit)
{
    Wnd.Close();
}

Does anyone have a possible solution to this?

Regards,
SS
RE: JIT - Debug popups by Spunky on 04-05-2010 at 10:10 PM

Wnd is usually a Plus! window that you have opened. Either the variable Wnd is not created or the variable is being declared in the wrong scope (local instead of global).

To make sure the variable is in the right scope, put "var Wnd;" outside all functions and change the line that opens the window to "Wnd = MsgPlus.CreateWnd('interface.xml', 'myWindow');"

If that gives the same error  then the window is just not being created, possibly due to an error in the XML markup


RE: JIT - Debug popups by SmokingCookie on 04-07-2010 at 02:53 PM

You need to provide the ExitCode parameter as well:

JScript code:
function OnEvent_Uninitialize(MessengerExit)
{
    Wnd.Close(0 /* numeric value */);
}


RE: JIT - Debug popups by SiliconShadow on 06-06-2010 at 12:04 PM

Sorry I didn't check back after a couple of days and just looked again today, so I am again sorry for resurrecting this issues.

To add some things:
I do now have any extensions installed
I have not made anything myself for this
This is just with Messenger Plus installed ontop of my MSN nothing else
I cannot edit that line or I would of done that already

Example of receiving the error: Start msn with Messenger Plus installed, Exit the program, Receive Runtime error:

---------------------------
Microsoft Development Environment
---------------------------
An exception of type 'Microsoft JScript runtime error: 'Wnd' is null or not an object' was not handled.
---------------------------
OK   
---------------------------

This error doesn't happen with Messenger Plus installed, however it is just annoying but I am hoping there is a proper fix.

The code from the file:
Notes: var WnD is initialised, the error is on line 40

code:
var Wnd;

function OnGetScriptMenu(Location)
{
    var ScriptMenu = "<ScriptMenu>";
    ScriptMenu += "<MenuEntry Id=\"MnuStart\">Edit Name</MenuEntry>";
    ScriptMenu += "</ScriptMenu>";
    return ScriptMenu;
}

function OnEvent_MenuClicked(MenuItemId, Location, OriginWnd)
{
    if(MenuItemId == "MnuStart")
    {
        Wnd = MsgPlus.CreateWnd("NameEditor.xml", "WndMain");
        Wnd.SetControlText("NameEdit", Messenger.MyName);
        Wnd.SetControlText("NameEditPreview", Messenger.MyName);
        Wnd.SendControlMessage('NameEdit', 0xC5, 129, 0);
        Wnd.Combo_AddItem("NamePm", "Name");
        Wnd.Combo_AddItem("NamePm", "Personal Message");
        Wnd.Combo_SetCurSel("NamePm", 0);
        //Wnd.ImageElmt_SetImageFile("emoticon", "WLM_1");
        var len = Wnd.GetControlText("NameEdit").length;
        var EM_SETSEL = 0xB1;
        Interop.Call("user32","SetFocus", Wnd.GetControlHandle("NameEdit"));
        Interop.Call("user32","SendMessageW", Wnd.GetControlHandle("NameEdit"), EM_SETSEL, len, len);
    }
}

function OnWndMainEvent_ComboSelChanged()
{
    if(Wnd.Combo_GetCurSel("NamePm") == 0)
        Wnd.SetControlText("NameEdit", Messenger.MyName);
    else
        Wnd.SetControlText("NameEdit", Messenger.MyPersonalMessage);
}

function OnEvent_Uninitialize(MessengerExit)
{
/*******************
* The error is here
*******************/
    Wnd.Close();
}

function OnWndMainEvent_CtrlClicked(Wnd, ControlId)
{
    // Two Win32 Messages that we will need to send later
    var EM_GETSEL = 0xB0;
    var EM_SETSEL = 0xB1;
    // Allocate some memory for the cursor index
    var Start = Interop.Allocate(4);
    // Number of characters to move the cursor on by later
    var numCharsAdded = 1;
    // Get where the cursor is in the input box
    Interop.Call("user32", "SendMessageW", Wnd.GetControlHandle("NameEdit"), EM_GETSEL, Start, 0);
    // Split the string into two parts on either side of the cursor so we can insert characters in the middle
    var text = Wnd.GetControlText("NameEdit");
    var firstHalf = text.substring(0, Start.ReadDWORD(0));
    var secondHalf = text.substring(Start.ReadDWORD(0), text.length);   
   
    // Insert format codes when the format buttons are pressed
    if(ControlId == "BtnBold")
    {
        Wnd.SetControlText("NameEdit", firstHalf + "·#" + secondHalf);
        numCharsAdded = 2;
    }
    if(ControlId == "BtnUnderline")
    {
        Wnd.SetControlText("NameEdit", firstHalf + "·@" + secondHalf);
        numCharsAdded = 2;
    }
    if(ControlId == "BtnItalic")
    {
        Wnd.SetControlText("NameEdit", firstHalf + "·&" + secondHalf);
        numCharsAdded = 2;
    }
    if(ControlId == "BtnStrikethrough")
    {
        Wnd.SetControlText("NameEdit", firstHalf + "·'" + secondHalf);
        numCharsAdded = 2;
    }
    if(ControlId == "BtnColour")
    {
        var CHOOSECOLOR = Interop.Allocate(36);
        CHOOSECOLOR.WriteDWORD(0, 36); //DWORD lStructSize
        CHOOSECOLOR.WriteDWORD(4, 0); //HWND hwndOwner
        CHOOSECOLOR.WriteDWORD(8, 0); //HWND hInstance
        CHOOSECOLOR.WriteDWORD(12, 0x000000FF); //COLORREF rgbResult (COLORREF = 0x00bbggrr)
        var CustColors = Interop.Allocate(64); //Create an array of 16 COLORREFs for CustColors
        CHOOSECOLOR.WriteDWORD(16, CustColors.DataPtr); //COLORREF *lpCustColors (pointer to our array)
        CHOOSECOLOR.WriteDWORD(20, 3); //DWORD Flags (3 = 2 (CC_FULLOPEN) + 1 (CC_RGBINIT) )
        CHOOSECOLOR.WriteDWORD(24, 0); //LPARAM lCustData
        CHOOSECOLOR.WriteDWORD(28, 0); //LPCCHOOKPROC lpfnHook
        CHOOSECOLOR.WriteDWORD(32, 0); //LPCTSTR lpTemplateName

        //Open the dialog box
        var result = Interop.Call('comdlg32.dll', 'ChooseColorA', CHOOSECOLOR);
        //If the user pressed ok convert it to hex
        if(result == 1)
        {
              //Get decimal values
              var r = CHOOSECOLOR.ReadDWORD(12) & 0xFF;
              var g = (CHOOSECOLOR.ReadDWORD(12) / 0x100) & 0xFF;
              var b = (CHOOSECOLOR.ReadDWORD(12) / 0x10000) & 0xFF;
              //Get hex values
              var hexchars="0123456789ABCDEF";
              var r = hexchars.charAt((r >> 4) & 0xf) + hexchars.charAt(r & 0xF);
              var g = hexchars.charAt((g >> 4) & 0xf) + hexchars.charAt(g & 0xF);
              var b = hexchars.charAt((b >> 4) & 0xf) + hexchars.charAt(b & 0xF);
              Wnd.SetControlText("NameEdit", firstHalf + "·$#" + r + g + b + secondHalf);
              numCharsAdded = 9;
        } else {
            Wnd.SetControlText("NameEdit", firstHalf + "·$" + secondHalf);
            numCharsAdded = 2;
        }
    }
    if(ControlId == "BtnBlack")
    {
        Wnd.SetControlText("NameEdit", firstHalf + "·$1" + secondHalf);
        numCharsAdded = 3;
    }
   
    // Insert special characters when their buttons are pressed
    if(ControlId == "BtnA")
        Wnd.SetControlText("NameEdit", firstHalf + "&#945;" + secondHalf);
    if(ControlId == "BtnE")
        Wnd.SetControlText("NameEdit", firstHalf + "&#949;" + secondHalf);
    if(ControlId == "BtnH")
        Wnd.SetControlText("NameEdit", firstHalf + "&#1085;" + secondHalf);
    if(ControlId == "BtnI")
        Wnd.SetControlText("NameEdit", firstHalf + "&#953;" + secondHalf);
    if(ControlId == "BtnN")
        Wnd.SetControlText("NameEdit", firstHalf + "&#331;" + secondHalf);
    if(ControlId == "BtnNN")
        Wnd.SetControlText("NameEdit", firstHalf + "&#1080;" + secondHalf);
    if(ControlId == "BtnNNN")
        Wnd.SetControlText("NameEdit", firstHalf + "&#1048;" + secondHalf);
    if(ControlId == "BtnO")
        Wnd.SetControlText("NameEdit", firstHalf + "&#963;" + secondHalf);
    if(ControlId == "BtnP")
        Wnd.SetControlText("NameEdit", firstHalf + "&#961;" + secondHalf);
    if(ControlId == "BtnR")
        Wnd.SetControlText("NameEdit", firstHalf + "&#1103;" + secondHalf);
    if(ControlId == "BtnT")
        Wnd.SetControlText("NameEdit", firstHalf + "&#1090;" + secondHalf);
    if(ControlId == "BtnU")
        Wnd.SetControlText("NameEdit", firstHalf + "&#965;" + secondHalf);
    if(ControlId == "BtnW")
        Wnd.SetControlText("NameEdit", firstHalf + "&#969;" + secondHalf);
    if(ControlId == "BtnY")
        Wnd.SetControlText("NameEdit", firstHalf + "&#1095;" + secondHalf);
    if(ControlId == "BtnYY")
        Wnd.SetControlText("NameEdit", firstHalf + "&#1063;" + secondHalf);
    if(ControlId == "BtnTm")
        Wnd.SetControlText("NameEdit", firstHalf + "™" + secondHalf);
    if(ControlId == "BtnCross")
        Wnd.SetControlText("NameEdit", firstHalf + "†" + secondHalf);
    if(ControlId == "BtnRArrow")
        Wnd.SetControlText("NameEdit", firstHalf + "»" + secondHalf);
    if(ControlId == "BtnLArrow")
        Wnd.SetControlText("NameEdit", firstHalf + "«" + secondHalf);
    if(ControlId == "BtnB")
        Wnd.SetControlText("NameEdit", firstHalf + "&#1074;" + secondHalf);
    if(ControlId == "BtnK")
        Wnd.SetControlText("NameEdit", firstHalf + "&#1082;" + secondHalf);
    if(ControlId == "BtnM")
        Wnd.SetControlText("NameEdit", firstHalf + "&#1084;" + secondHalf);
       
    // Set focus back to the edit box and then move the cursor back to where it was
    Interop.Call("user32","SetFocus", Wnd.GetControlHandle("NameEdit"));
    Interop.Call("user32","SendMessageW", Wnd.GetControlHandle("NameEdit"), EM_SETSEL, Start.ReadDWORD(0) + numCharsAdded, Start.ReadDWORD(0) + numCharsAdded);
   
    // The save and the close button
    if(ControlId == "BtnClose")
        Wnd.Visible = false;
    if(ControlId == "BtnSet")
    {
        if(Wnd.Combo_GetCurSel("NamePm") == 0)
            Messenger.MyName = Wnd.GetControlText("NameEdit");
        else
            Messenger.MyPersonalMessage = Wnd.GetControlText("NameEdit");
    }
}

function OnWndMainEvent_EditTextChanged(Wnd, ControlId)
{
    if(ControlId == "NameEdit")
        Wnd.SetControlText("NameEditPreview", Wnd.GetControlText("NameEdit"));
}

ps. I have turned on e-mail notification so I will be able to reply more promptly in the future.
RE: JIT - Debug popups by SmokingCookie on 06-06-2010 at 04:03 PM

I think this error occurs only when you restart or uload the script if you have not clicked the menu item yet. If otherwise, please make sure the XML document is valid and no ControlID is assigned to more than one control.

(Edit: same goes for ElementIDs)


RE: JIT - Debug popups by SiliconShadow on 06-06-2010 at 04:50 PM

As I said it occurs on my machine after a clean install of MSN and Messenger Plus with no scripts, and it happens when closing MSN even if I do not login.

I havn't been able to find a way of stopping this error.

Conditions:
Vista Ultimate x64 All service updates and patches
.net - up to date
Visual studio 2008 express
MSN
Messenger Plus

Action:
Run msn then choose "Exit"

What happens:
Script error as described in the above posts


RE: JIT - Debug popups by Mnjul on 06-06-2010 at 04:54 PM

I'm pretty sure you have WLNameEditor installed. Is it present in your Preferences' Script section?


RE: RE: JIT - Debug popups by SiliconShadow on 06-06-2010 at 05:13 PM

quote:
Originally posted by Mnjul
I'm pretty sure you have WLNameEditor installed. Is it present in your Preferences' Script section?

No it isn't, could it be a cache problem them because I did have it installed, I will try and clear out precache.
RE: JIT - Debug popups by SmokingCookie on 06-06-2010 at 05:18 PM

The problem with your script is, that the window must have been created, before you can destroy it. You should be able to overcome this problem by replacing the faulty line with this:

JScript code:
    if(typeof Wnd === "object" && Wnd !== null) Wnd.Close();


I'm pretty sure this'll do it... *-)
RE: JIT - Debug popups by SiliconShadow on 06-06-2010 at 05:23 PM

I have cleared the precache and the error is gone. Thank you.

<solved>

@The above poster I am unable to edit the script it doesn't exist, so even with no scripts enabled I was getting this error, which led me to beleive it was MSN Plus however it wasn't.


RE: RE: JIT - Debug popups by CookieRevised on 06-10-2010 at 10:36 AM

The error came from an installed script (the reasons for the error are explained by SmokingCookie).

However, that source you showed seems to be a (older?) buggy version of WLNameEditor as Mnjul said. The version listed in the scripting database does not have that error.

All installed scripts should appear in the scripting preferences:
Plus! > Preferences & Options > General > Scripts

If there is a script running, but it isn't listed in that list, then you have some serious (other) problems. I have never heared of this happening before though, nor have I heared of cache problems like that.


PS: Users do not need to be logged in into Messenger for scripts to run. Scripts start running the moment you start Messenger (and Plus! is loaded). A user logging in is just another event which scripts can interact with. This also means that scripts will not stop running when the user signs out.

------------------------

What do you mean with "precache"???
Can you explain in great detail how you cleared this "precache"?

Messenger Plus! nor Messenger doesn't use any cache (that is: for scripting or stuff like that). Your Temporary Internet Files or any other form of cache from other programs should not have any influence at all on Plus! or Messenger. But since you had that error, it sure wasn't a "clean install" though.

Anyways, if you couldn't edit the script then how did you manage to show the source of it? Where did that came from? Can you explain in detail how you got that source (from what location)?


RE: JIT - Debug popups by SiliconShadow on 06-11-2010 at 05:35 PM

The precached data from vistas 'Superfetch' C:\Windows\Prefetch which caches Programs and Data used in the program, sometimes it isn't seen as updated and errors don't go away.

This isn't something that I would recommend playing with unless you know what to do, but I remember reading a MSN article on having to clear it for some errors, so after it was mentioned that it was a script that had been on previously but removed that caused this error I knew where to look.


RE: JIT - Debug popups by CookieRevised on 06-11-2010 at 06:22 PM

[sie=1]the prefetch in XP or superfetch in Visa != cache[/size]

Anyways, if it was Vista's Superfetch causing the error, then there is something wrong with your Superfetch settings as a removed file (in this case the old WLNameEditor script) should not be loaded/referenced from he Superfetch storage anymore, but instead should automatically be removed from it. If it wasn't removed (it clearly wasn't) then there is either something wrong with your superftech storage or your superftech doesn't update itself due to low battery power.

How you ever tweaked the Superfetch in one way or the other before? Or are you, by any chance, always running on low/not-full battery power on your laptop (in case it was a laptop you had this problem with)?