Newest Version of my script doesnt start up - 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: Newest Version of my script doesnt start up (/showthread.php?tid=90668)
Newest Version of my script doesnt start up by xXDarknessXx on 05-17-2009 at 07:14 AM
I recently updated my script [xXDarknessXx Detach] to add a new funtion and fixed a few bugs but doing so created a new one .
When I sign into WLM i check the script menu and my menu isnt their, its not in the / commands either, so i thought just might be a broken like or an error so I went into script editor and did save so I could see all the errors but no errors came up and it started working fine. I then restart WLM and it wasnt working again, it is ticked in the scripts window so it is enabled but i opened the debug window and it doesnt open any the functions untill ive gone in and saved it here is my code its a little long but yea could someone please try and find the problem
code: var emails;
var items;
var lEm;
var Shell = new ActiveXObject("WScript.Shell");
var closeDetach;
var s_unknown = 0;
var s_offline = 1;
var s_appearoffline = 2;
var s_online = 3;
var s_busy = 4;
var s_brb = 5;
var s_idle = 6;
var s_away = 7;
var s_onphone = 8;
var s_outlunch = 9;
var ContactListMenuLoc = 1;
var ChatWindowMenuLoc = 2;
var RegPath1 = "HKEY_CURRENT_USER\\SOFTWARE\\Patchou\\Messenger Plus! Live";
var RegPath2 = "\\"
var RegPath3 = Messenger.MyEmail + "\\Preferences\\TabChatAuto";
var RegPath = RegPath1 + RegPath2 + RegPath3;
var TabbedEnabled = Shell.RegRead(RegPath);
var DetachDisabled;
var DispNote;
function OnEvent_Initialize(MessengerStart)
{
StartDetach();
}
function StartDetach()
{
try
{
read('DarkCheck');
try
{
read('AutoClose');
}
catch(ex)
{
write("AutoClose","false");
}
try
{
read('DispNote');
}
catch(ex)
{
write("DispNote","true");
}
}
catch(ex)
{
write("emails","");
write("DarkCheck");
write("AutoClose","false");
write("DispNote","true");
}
DispNote = read('DispNote');
closeDetach = read('AutoClose');
if(closeDetach == "true")
{
closeDetach = true;
}
else
{
closeDetach = false;
}
lEm = read('emails');
if(TabbedEnabled == 0)
{
if(DispNote == "true")
{
DetachDisabled = true;
var Wnd = MsgPlus.CreateWnd("Interface.xml", "WndTabbed");
}
}
else
{
write("DispNote","true");
Shell.RegWrite(RegPath, 1,"REG_DWORD");
DetachDisabled = false;
}
}
function OnEvent_ChatWndSendMessage( oChatWnd, sMessage )
{
var Message = sMessage.toLowerCase();
if(DetachDisabled == false)
{
if (Message == "/detachoptions")
{
Debug.Trace("Dark Detach Option");
OpenOptions();
return '';
}
else if (Message == "/detach" )
{
detachcurrent(oChatWnd);
return '';
}
else if (Message == "/detachabout" )
{
AboutWindow();
return '';
}
}
else
{
if (Message == "/detachenable" )
{
Shell.RegWrite(RegPath, 1,"REG_DWORD");
DetachDisabled = false;
return '';
}
}
}
function OnGetScriptCommands()
{
if(DetachDisabled == false)
{
var commands = "<ScriptCommands>";
commands += "<Command>";
commands += "<Name>DetachOptions</Name>";
commands += "<Description>Opens the Detach options</Description>";
commands += "</Command>";
commands += "<Command>";
commands += "<Name>Detach</Name>";
commands += "<Description>Detaches Current Chat</Description>";
commands += "</Command>";
commands += "<Command>";
commands += "<Name>DetachAbout</Name>";
commands += "<Description>Detach Info</Description>";
commands += "</Command>";
commands += "</ScriptCommands>";
}
else
{
var commands = "<ScriptCommands>";
commands += "<Command>";
commands += "<Name>DetachEnable</Name>";
commands += "<Description>Enable tabbed chats and Detach Tabs</Description>";
commands += "</Command>";
commands += "</ScriptCommands>";
}
Debug.Trace(commands)
return commands;
}
function OnGetScriptMenu(nLocation)
{
Debug.Trace("Location = " + nLocation)
var menu;
if(DetachDisabled == false)
{
switch(nLocation)
{
case ChatWindowMenuLoc:
Debug.Trace("Script Menu Chat Window");
menu = "<ScriptMenu>";
menu += "<MenuEntry Id=\"Detach\">Detach Current Chat</MenuEntry>";
menu += "<Separator/>";
menu += menuGet();
break;
case ContactListMenuLoc:
Debug.Trace("Script Menu Contact Window")
menu = "<ScriptMenu>";
menu += menuGet();
break;
default:
Debug.Trace("Script Menu Other")
menu = "<ScriptMenu>";
menu += menuGet();
break;
}
}
else
{
menu = "<ScriptMenu>";
menu += "<MenuEntry Id=\"EnableDetach\">Enable Tabbed Chats and Detach</MenuEntry>";
menu += "<Separator/>"
menu += "</ScriptMenu>";
}
return menu;
}
function menuGet()
{
var menu2;
menu2 = "<MenuEntry Id=\"AutoCloseOp\">" + AutoClose() + " Autoclose on Detach</MenuEntry>";
menu2 += "<MenuEntry Id=\"Options\">Detach Options</MenuEntry>";
menu2 += "<Separator/>";
menu2 += "<MenuEntry Id=\"About\">About Darkness's Detach</MenuEntry>";
menu2 += "</ScriptMenu>";
return menu2;
}
function AutoClose()
{
Debug.Trace("Get AutoClose")
if(closeDetach == true)
return "Disable";
else
return "Enable";
}
function OnEvent_MenuClicked (sId, nLocation, iWnd)
{
var function_handler = sId + "_menuclicked";
if (eval("typeof(" + function_handler + ")") == "function")
{
eval(function_handler + "(nLocation, iWnd);");
}
}
function Detach_menuclicked (nLocation, Wnd)
{
switch(nLocation)
{
case ChatWindowMenuLoc:
detachcurrent(Wnd);
break;
case ContactListMenuLoc:
break;
default:
break;
}
}
function EnableDetach_menuclicked (nLocation, Wnd)
{
Shell.RegWrite(RegPath, 1,"REG_DWORD");
DetachDisabled = false;
}
function AutoCloseOp_menuclicked(nLocation, Wnd)
{
var CloseVar;
if(closeDetach == true)
{
closeDetach = false;
write("AutoClose","false");
}
else
{
closeDetach = true;
write("AutoClose","true");
}
}
function Options_menuclicked (nLocation, Wnd)
{
OpenOptions();
}
function About_menuclicked (nlocation,Wnd)
{
AboutWindow();
}
function AboutWindow()
{
var AboutWnd = MsgPlus.CreateWnd("Interface.xml", "WndAbout");
}
function detachcurrent(Email)
{
var WndContacts = Email.Contacts;
if(WndContacts.Count == 1)
{
var the = new Enumerator(WndContacts);
var Contact = the.item();
detachEmail = Contact.email;
if(closeDetach == true)
{
Email.SendMessage("/close");
}
}
Debug.Trace(detachEmail)
}
function OnEvent_ChatWndDestroyed(Email)
{
if(DetachDisabled == false)
{
var WndContacts = Email.Contacts;
if(WndContacts.Count == 1)
{
var the = new Enumerator(WndContacts);
var Contact = the.item();
if(detachEmail == Contact.email)
{
MsgPlus.AddTimer('detach', 1000);
}
}
}
}
function OnEvent_Timer(TimerId)
{
if(TimerId == 'detach')
{
OnDTClick(detachEmail);
Debug.Trace("Detach " + detachEmail);
detachEmail = "";
MsgPlus.CancelTimer('detach');
}
}
function OpenOptions()
{
var i;
var contacts;
contacts = new Enumerator(Messenger.MyContacts);
var Wnd = MsgPlus.CreateWnd("Interface.xml", "WndOps");
for (i = 0; !contacts.atEnd(); contacts.moveNext())
{
var contact = contacts.item();
var icon;
Wnd.LstView_AddItem("emails", "");
Wnd.LstView_SetItemText("emails", i, 1, MsgPlus.RemoveFormatCodes(contact.Name));
Wnd.LstView_SetItemText("emails", i, 2, contact.Email);
lEm = lEm.split(",");
for (var ii in lEm)
{
if (lEm[ii] == contact.Email)
{
Wnd.LstView_SetCheckedState("emails", i, true);
}
}
lEm = lEm.join(",");
switch (contact.Status)
{
case s_online:
icon = "online";
break;
case s_offline:
case s_appearoffline:
icon = "offline";
break;
case s_busy:
case s_onphone:
icon = "busy";
break;
case s_brb:
case s_idle:
case s_away:
case s_outlunch:
icon = "away";
break;
case s_unknown:
default:
icon = "";
break;
}
if (contact.Blocked)
{
if (icon != "" && icon != "offline")
{
icon = "blocked";
}
else
{
icon = "blocked-offline";
}
}
if (icon != "")
{
Wnd.LstView_SetItemIcon("emails", i, icon, true);
}
i++;
}
}
function fSave(Wnd)
{
var finish = Wnd.LstView_GetCount("emails");
lEm = "";
for (i = 0; i < finish; i++)
{
if(Wnd.LstView_GetCheckedState("emails", i))
{
if (lEm.substr(lEm.length - 1) != "," && lEm != "")
{
lEm += "," + Wnd.LstView_GetItemText("emails", i, 2); + ",";
}
else
{
lEm += Wnd.LstView_GetItemText("emails", i, 2); + ",";
}
}
}
closeDetach = Wnd.Button_IsChecked("cbxAutoClose");
write('emails', lEm.substr(0, lEm.length));
lEm = read('emails');
Wnd.Close(1);
}
function read(key)
{
return Shell.RegRead(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\" + key);
}
function write(key, value)
{
Shell.RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\" + key, value);
}
function OnDTClick(Email)
{
Shell.RegWrite(RegPath, 0,"REG_DWORD");
Messenger.OpenChat(Email);
Shell.RegWrite(RegPath, 1,"REG_DWORD");
}
function OnEvent_ContactSignin(Email)
{
if(DetachDisabled == false)
{
TheEmails = lEm.split(",");
if(Email !== Messenger.MyEmail)
{
for (var i in TheEmails)
{
if (Email == TheEmails[i])
{
MsgPlus.DisplayToastContact("Chat Detached" , Email, "Click to display in a seperate window", "", "OnDTClick", Email,Email );
}
}
}
}
}
function OnWndOpsEvent_CtrlClicked(Wnd, ControlId)
{
Debug.Trace(ControlId)
if (ControlId == "BtnOk")
{
fSave(Wnd);
}
if (ControlId == "BtnClose")
{
Wnd.Close(1);
}
/* if (ControlId == "BtnSearch")
{
txtSearch = "";
Search(txtSearch);
} */
if (ControlId == "BtnAbout")
{
AboutWindow();
}
}
function OnWndAboutEvent_CtrlClicked(AboutWnd, ControlId)
{
if (ControlId == "BtnClose")
{
AboutWnd.Close(1);
}
}
function OnWndTabbedEvent_CtrlClicked(AboutWnd, ControlId)
{
if (ControlId == "BtnYes")
{
Shell.RegWrite(RegPath, 1,"REG_DWORD");
DetachDisabled = false;
AboutWnd.Close(1);
}
if (ControlId == "BtnNo")
{
DispNote = false;
write("DispNote","false");
DetachDisabled = true;
AboutWnd.Close(1);
}
}
Thanks in advance
RE: Newest Version of my script doesnt start up by matty on 05-19-2009 at 12:53 PM
Use this instead
js code: function OnEvent_Initialize(MessengerStart) {
if (Messenger.MyStatus < STATUS_INVISIBLE) return false;
StartDetach();
}
function OnEvent_SigninReady(sEmail) {
OnEvent_Initialize(true);
}
The reason this is happening is because of the following:
When the script is started and no one is logged in the Messenger object isn't populated completely. By that I mean Messenger.MyEmail doesn't exist etc. When your script calls StartDetatch() you are trying to read the registry but because Messenger.MyEmail doesn't exist yet it fails. By checking if the user is logged in you can prevent this from happening. By adding the function OnEvent_SigninReady this is called when the entire login process is completed and the contact list is fully gathered from the servers.
RE: Newest Version of my script doesnt start up by xXDarknessXx on 05-19-2009 at 02:35 PM
thanks man =] it didnt fix it all because i used Messenger.Email higher up even before the Init Function but what you said made me realise my mistake so thanks =] u always seam to be the one helping me =P
RE: Newest Version of my script doesnt start up by matty on 05-19-2009 at 04:32 PM
Not a problem. Just as a rule of thumb don't make any reference to the Messenger object unless checking if the user is signed in. Hence Messenger.MyStatus < STATUS_INVISIBLE.
Cheers!
RE: RE: Newest Version of my script doesnt start up by sno on 05-29-2009 at 10:38 PM
quote: Originally posted by xXDarknessXx
thanks man =] it didnt fix it all because i used Messenger.Email higher up even before the Init Function but what you said made me realise my mistake so thanks =] u always seam to be the one helping me =P
Hi, im currentlly using 1.5
im getting a problem of it not remembering which contact's to actually display in there own window, they all end up in the tabbed.
|