Shoutbox

Online time - 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: Online time (/showthread.php?tid=65291)

Online time by Err0r on 08-23-2006 at 05:53 PM

Maybe you have seen the online time script. It shows how long you have been online since you logged in in your personal message.
But, is it any way to make a script that stores how long you have been online the last time, and adds that to the online time. It would be funny to see how long i`ve been on msn in 1 year :P

I hope you understand what i mean :P


RE: Online time by KnRd_WC on 08-24-2006 at 12:20 PM

Hi Err0r, sorry, but I thinked that somebody else will answer before me.... :S

I made a script, because I don't want to modify another script :
Go to the MP!L options, "General">"Scripts">"New". Remove everything in the new window, and copy-paste this code. (I think my script works fine....)

code:
function OnEvent_Initialize(MessengerStart) {
    shell=new ActiveXObject("WScript.Shell");
    if (MessengerStart==false) {
        regPath=MsgPlus.ScriptRegPath+Messenger.MyUserId+'\\';
        Initialize();
    }
}

function OnEvent_Signin(Email) {
    regPath=MsgPlus.ScriptRegPath+Messenger.MyUserId+'\\';
    Initialize();
}

function OnEvent_Signout(Email) {
MsgPlus.CancelTimer("Timer");
}

function OnEvent_Timer(TimerId) {
    seconds+=10
    shell.RegWrite(regPath+"Seconds",seconds);
   
    yr=parseInt(seconds/31536000);
    mon=parseInt((seconds-(yr*31536000))/2592000);
    day=parseInt((seconds-(yr*31536000)-(mon*2592000))/86400);
    hr=parseInt((seconds-(yr*31536000)-(mon*2592000)-(day*86400))/3600);
    min=parseInt((seconds-(yr*31536000)-(mon*2592000)-(day*86400)-(hr*3600))/60);
    secs=parseInt((seconds-(yr*31536000)-(mon*2592000)-(day*86400)-(hr*3600)-(min*60)));
   
    if (secs>0) {SECONDS=secs+" secondes ";}
    else {SECONDS="";}
    if (min>0) {MINS=min+" minutes ";
        if (secs!=0) {
            MINS+="et "
        }
    }
    else {MINS="";}
    if (hr>0) {HRS=hr+" heures ";}
    else {HRS="";}
    if (day>0) {DAYS=day+" jours ";}
    else {DAYS="";}
    if (mon>0) {MONTH=mon+" mois ";}
    else {MONTH="";}
    if (yr>0) {YEAR=yr+" an ";}
    else {YEAR="";}
    MsgPlus.AddTimer("Timer",10000);
    Messenger.MyPersonalMessage="Cela fait "+YEAR+MONTH+DAYS+HRS+MINS+SECONDS+"que je suis en ligne depuis le 24 Août 2006"; // Here you can modify your message
}

function Initialize() {
    try {seconds = parseInt(shell.RegRead(regPath+"Seconds"));} catch(err) {seconds=0;}
    MsgPlus.AddTimer("Timer",10000);
}


RE: Online time by Kenji on 08-24-2006 at 12:26 PM

KnRd_WC could you translate this script please?


RE: Online time by KnRd_WC on 08-24-2006 at 12:28 PM

Wow just wait a minute, lol, .parseInt() is only for string, so, at start : 6 years, 10 years, and at 50 seconds my script works fine.... lol I correct this error !
-------------------------
Edit : Mhhhh totally wrong.... .parseInt() works with numbers xD
-------------------------

code:
function OnEvent_Initialize(MessengerStart) {
    shell=new ActiveXObject("WScript.Shell");
    if (MessengerStart==false) {
        regPath=MsgPlus.ScriptRegPath+Messenger.MyUserId+'\\';
        Initialize();
    }
}

function OnEvent_Signin(Email) {
    regPath=MsgPlus.ScriptRegPath+Messenger.MyUserId+'\\';
    Initialize();
}

function OnEvent_Signout(Email) {
MsgPlus.CancelTimer("Timer");
}

function OnEvent_Timer(TimerId) {
    seconds+=10
    shell.RegWrite(regPath+"Seconds",seconds);
   
    yr=parseInt(seconds/31536000);
    mon=parseInt((seconds-(yr*31536000))/2592000);
    day=parseInt((seconds-(yr*31536000)-(mon*2592000))/86400);
    hr=parseInt((seconds-(yr*31536000)-(mon*2592000)-(day*86400))/3600);
    min=parseInt((seconds-(yr*31536000)-(mon*2592000)-(day*86400)-(hr*3600))/60);
    secs=parseInt((seconds-(yr*31536000)-(mon*2592000)-(day*86400)-(hr*3600)-(min*60)));
   
    if (secs>0) {SECONDS=secs+" seconds ";}
    else {SECONDS="";}
    if (min>0) {MINS=min+" minutes ";
        if (secs!=0) {
            MINS+="and "
        }
    }
    else {MINS="";}
    if (hr>0) {HRS=hr+" hours ";}
    else {HRS="";}
    if (day>0) {DAYS=day+" days ";}
    else {DAYS="";}
    if (mon>0) {MONTH=mon+" months ";}
    else {MONTH="";}
    if (yr>0) {YEAR=yr+" year ";}
    else {YEAR="";}
    MsgPlus.AddTimer("Timer",10000);
    Messenger.MyPersonalMessage="There are "+YEAR+MONTH+DAYS+HRS+MINS+SECONDS+"since I am connected"; // wow, fu*** translator xD
}


function Initialize() {
    try {seconds = parseInt(shell.RegRead(regPath+"Seconds"));} catch(err) {seconds=0;}
    MsgPlus.AddTimer("Timer",10000);
}


Sorry but I used a translator... :S There is a little bug at start, you will see.... but at 50 secs, the script should work fine. I can't correct this error, now, I got to go... :(
RE: Online time by NiteMare on 08-24-2006 at 01:17 PM

quote:
Originally posted by KnRd_WC
function OnEvent_Initialize(MessengerStart) {
shell=new ActiveXObject("WScript.Shell");
if (MessengerStart==false) {
regPath=MsgPlus.ScriptRegPath+Messenger.MyUserId+'\\';
Initialize();
}
}

function OnEvent_Signin(Email) {
regPath=MsgPlus.ScriptRegPath+Messenger.MyUserId+'\\';
Initialize();
}

function OnEvent_Signout(Email) {
MsgPlus.CancelTimer("Timer");
}

function OnEvent_Timer(TimerId) {
seconds+=10
shell.RegWrite(regPath+"Seconds",seconds);

yr=parseInt(seconds/31536000);
mon=parseInt((seconds-(yr*31536000))/2592000);
day=parseInt((seconds-(yr*31536000)-(mon*2592000))/86400);
hr=parseInt((seconds-(yr*31536000)-(mon*2592000)-(day*86400))/3600);
min=parseInt((seconds-(yr*31536000)-(mon*2592000)-(day*86400)-(hr*3600))/60);
secs=parseInt((seconds-(yr*31536000)-(mon*2592000)-(day*86400)-(hr*3600)-(min*60)));

if (secs>0) {SECONDS=secs+" seconds ";}
else {SECONDS="";}
if (min>0) {MINS=min+" minutes ";
if (secs!=0) {
MINS+="and "
}
}
else {MINS="";}
if (hr>0) {HRS=hr+" hours ";}
else {HRS="";}
if (day>0) {DAYS=day+" days ";}
else {DAYS="";}
if (mon>0) {MONTH=mon+" months ";}
else {MONTH="";}
if (yr>0) {YEAR=yr+" year ";}
else {YEAR="";}
MsgPlus.AddTimer("Timer",10000);
Messenger.MyPersonalMessage="There are "+YEAR+MONTH+DAYS+HRS+MINS+SECONDS+"since I am connected"; // wow, fu*** translator xD
}


function Initialize() {
try {seconds = parseInt(shell.RegRead(regPath+"Seconds"));} catch(err) {seconds=0;}
MsgPlus.AddTimer("Timer",10000);
}


english translation
code:
Messenger.MyPersonalMessage="I've been connected for "+YEAR+MONTH+DAYS+HRS+MINS+SECONDS; // wow, fu*** translator xD


RE: Online time by Err0r on 08-24-2006 at 01:37 PM

Thanks :D
i`ll test it


RE: Online time by skyserpent on 08-24-2006 at 01:48 PM

its not showing up in my psm


RE: Online time by KnRd_WC on 08-24-2006 at 04:18 PM

Works fine for me.... This script should be better ;)

code:
function OnEvent_Initialize(MessengerStart) {
    shell=new ActiveXObject("WScript.Shell");
    if (MessengerStart==false) {
        regPath=MsgPlus.ScriptRegPath+Messenger.MyUserId+'\\';
        Initialize();
    }
}

function OnEvent_Signin(Email) {
    regPath=MsgPlus.ScriptRegPath+Messenger.MyUserId+'\\';
    Initialize();
}

function OnEvent_Signout(Email) {
    MsgPlus.CancelTimer("Timer");
}

function OnEvent_Uninitialize(MessengerExit) {
    MsgPlus.CancelTimer("Timer");
}

function OnEvent_Timer(TimerId) {
    seconds+=10
    shell.RegWrite(regPath+"Seconds",seconds);
   
    yr=Math.floor(seconds/31536000);
    mon=Math.floor((seconds-(yr*31536000))/2592000);
    day=Math.floor((seconds-((yr*31536000)+(mon*2592000)))/86400);
    hr=Math.floor((seconds-((yr*31536000)+(mon*2592000)+(day*86400)))/3600);
    min=Math.floor((seconds-((yr*31536000)+(mon*2592000)+(day*86400)+(hr*3600)))/60);
    secs=Math.floor((seconds-((yr*31536000)+(mon*2592000)+(day*86400)+(hr*3600)+(min*60))));
   
    if (secs>0) {SECONDS=" "+secs+" seconds";}
    else {SECONDS="";}
    if (min==1) {MINS=" "+min+" minute";}
    else if (min>1) {MINS=" "+min+" minutes";}
    else {MINS="";}
    if (secs!=0&&min>0) {
        MINS+=" and"
    }
    if (hr==1) {HRS=" "+hr+" hour";}
    else if (hr>1) {HRS=" "+hr+" hours";}
    else {HRS="";}
    if (day==1) {DAYS=" "+day+" day";}
    if (day>1) {DAYS=" "+day+" days";}
    else {DAYS="";}
    if (mon==1) {MONTH=" "+mon+" month";}
    else if (mon>1) {MONTH=" "+mon+" months";}
    else {MONTH="";}
    if (yr==1) {YEAR=" "+yr+" year";}
    if (yr>1) {YEAR=" "+yr+" years";}
    else {YEAR="";}
    MsgPlus.AddTimer("Timer",10000);
    Messenger.MyPersonalMessage="I've been connected for"+YEAR+MONTH+DAYS+HRS+MINS+SECONDS;
}


function Initialize() {
    try {seconds = parseInt(shell.RegRead(regPath+"Seconds"));} catch(err) {seconds=0;}
    MsgPlus.AddTimer("Timer",10000);
}

Thanks for the translation NiteMare :D

Note : " "+secs+" seconds" >> I could put the space at the end, but the pm will be ".... 20 seconds "<< I don't want this space here ! xD

RE: Online time by skyserpent on 08-24-2006 at 04:24 PM

Function called: OnEvent_Signin
Function called: OnEvent_Timer
Error: 'shell' is undefined.
       Line: 24. Code: -2146823279.
Function OnEvent_Timer returned an error. Code: -2147352567

help!


RE: Online time by KnRd_WC on 08-24-2006 at 04:44 PM

Lol, sorry :

code:
shell=new ActiveXObject("WScript.Shell");

function OnEvent_Initialize(MessengerStart) {
    if (MessengerStart==false) {
        regPath=MsgPlus.ScriptRegPath+Messenger.MyUserId+'\\';
        Initialize();
    }
}

function OnEvent_Signin(Email) {
    regPath=MsgPlus.ScriptRegPath+Messenger.MyUserId+'\\';
    Initialize();
}

function OnEvent_Signout(Email) {
    MsgPlus.CancelTimer("Timer");
}

function OnEvent_Uninitialize(MessengerExit) {
    MsgPlus.CancelTimer("Timer");
}

function OnEvent_Timer(TimerId) {
    seconds+=10
    shell.RegWrite(regPath+"Seconds",seconds);
   
    yr=Math.floor(seconds/31536000);
    mon=Math.floor((seconds-(yr*31536000))/2592000);
    day=Math.floor((seconds-((yr*31536000)+(mon*2592000)))/86400);
    hr=Math.floor((seconds-((yr*31536000)+(mon*2592000)+(day*86400)))/3600);
    min=Math.floor((seconds-((yr*31536000)+(mon*2592000)+(day*86400)+(hr*3600)))/60);
    secs=Math.floor((seconds-((yr*31536000)+(mon*2592000)+(day*86400)+(hr*3600)+(min*60))));
   
    if (secs>0) {SECONDS=" "+secs+" seconds";}
    else {SECONDS="";}
    if (min==1) {MINS=" "+min+" minute";}
    else if (min>1) {MINS=" "+min+" minutes";}
    else {MINS="";}
    if (secs!=0&&min>0) {
        MINS+=" and"
    }
    if (hr==1) {HRS=" "+hr+" hour";}
    else if (hr>1) {HRS=" "+hr+" hours";}
    else {HRS="";}
    if (day==1) {DAYS=" "+day+" day";}
    if (day>1) {DAYS=" "+day+" days";}
    else {DAYS="";}
    if (mon==1) {MONTH=" "+mon+" month";}
    else if (mon>1) {MONTH=" "+mon+" months";}
    else {MONTH="";}
    if (yr==1) {YEAR=" "+yr+" year";}
    if (yr>1) {YEAR=" "+yr+" years";}
    else {YEAR="";}
    MsgPlus.AddTimer("Timer",10000);
    Messenger.MyPersonalMessage="I've been connected for"+YEAR+MONTH+DAYS+HRS+MINS+SECONDS;
}


function Initialize() {
    try {seconds = parseInt(shell.RegRead(regPath+"Seconds"));} catch(err) {seconds=0;}
    MsgPlus.AddTimer("Timer",10000);
}


RE: Online time by skyserpent on 08-24-2006 at 04:49 PM

Error: Expected '}'.
       Line: 63. Code: -2146827279.

cries lol


RE: Online time by KnRd_WC on 08-24-2006 at 05:03 PM

Are you sure ??? Verify your copy-paste (lol) xD

Sorry for very long posts :S

code:
shell=new ActiveXObject("WScript.Shell");

function OnEvent_Initialize(MessengerStart) {
if (MessengerStart==false) {
regPath=MsgPlus.ScriptRegPath+Messenger.MyUserId+'\\';
Initialize();
}
}

function OnEvent_Signin(Email) {
regPath=MsgPlus.ScriptRegPath+Messenger.MyUserId+'\\';
Initialize();
}

function OnEvent_Signout(Email) {
MsgPlus.CancelTimer("Timer");
}

function OnEvent_Uninitialize(MessengerExit) {
MsgPlus.CancelTimer("Timer");
}

function OnEvent_Timer(TimerId) {
seconds+=10
shell.RegWrite(regPath+"Seconds",seconds);

yr=Math.floor(seconds/31536000);
mon=Math.floor((seconds-(yr*31536000))/2592000);
day=Math.floor((seconds-((yr*31536000)+(mon*2592000)))/86400);
hr=Math.floor((seconds-((yr*31536000)+(mon*2592000)+(day*86400)))/3600);
min=Math.floor((seconds-((yr*31536000)+(mon*2592000)+(day*86400)+(hr*3600)))/60);
secs=Math.floor((seconds-((yr*31536000)+(mon*2592000)+(day*86400)+(hr*3600)+(min*60))));

if (secs>0) {SECONDS=" "+secs+" seconds";}
else {SECONDS="";}
if (min==1) {MINS=" "+min+" minute";}
else if (min>1) {MINS=" "+min+" minutes";}
else {MINS="";}
if (secs!=0&&min>0) {MINS+=" and";}
if (hr==1) {HRS=" "+hr+" hour";}
else if (hr>1) {HRS=" "+hr+" hours";}
else {HRS="";}
if (day==1) {DAYS=" "+day+" day";}
if (day>1) {DAYS=" "+day+" days";}
else {DAYS="";}
if (mon==1) {MONTH=" "+mon+" month";}
else if (mon>1) {MONTH=" "+mon+" months";}
else {MONTH="";}
if (yr==1) {YEAR=" "+yr+" year";}
if (yr>1) {YEAR=" "+yr+" years";}
else {YEAR="";}
MsgPlus.AddTimer("Timer",10000);
Messenger.MyPersonalMessage="I've been connected for"+YEAR+MONTH+DAYS+HRS+MINS+SECONDS;
}


function Initialize() {
try {seconds = parseInt(shell.RegRead(regPath+"Seconds"));} catch(err) {seconds=0;}
MsgPlus.AddTimer("Timer",10000);
}

I verified this script, and, for me, there is no problem... :S
RE: Online time by skyserpent on 08-24-2006 at 05:18 PM

i have

code:
shell=new ActiveXObject("WScript.Shell");

function OnEvent_Initialize(MessengerStart) {
if (MessengerStart==false) {
regPath=MsgPlus.ScriptRegPath+Messenger.MyUserId+'\\';
Initialize();
}
}

function OnEvent_Signin(Email) {
regPath=MsgPlus.ScriptRegPath+Messenger.MyUserId+'\\';
Initialize();
}

function OnEvent_Signout(Email) {
MsgPlus.CancelTimer("Timer");
}

function OnEvent_Uninitialize(MessengerExit) {
MsgPlus.CancelTimer("Timer");
}

function OnEvent_Timer(TimerId) {
seconds+=10
shell.RegWrite(regPath+"Seconds",seconds);

yr=Math.floor(seconds/31536000);
mon=Math.floor((seconds-(yr*31536000))/2592000);
day=Math.floor((seconds-((yr*31536000)+(mon*2592000)))/86400);
hr=Math.floor((seconds-((yr*31536000)+(mon*2592000)+(day*86400)))/3600);
min=Math.floor((seconds-((yr*31536000)+(mon*2592000)+(day*86400)+(hr*3600)))/60);
secs=Math.floor((seconds-((yr*31536000)+(mon*2592000)+(day*86400)+(hr*3600)+(min*60))));

if (secs>0) {SECONDS=" "+secs+" seconds";}
else {SECONDS="";}
if (min==1) {MINS=" "+min+" minute";}
else if (min>1) {MINS=" "+min+" minutes";}
else {MINS="";}
if (secs!=0&&min>0) {MINS+=" and";}
if (hr==1) {HRS=" "+hr+" hour";}
else if (hr>1) {HRS=" "+hr+" hours";}
else {HRS="";}
if (day==1) {DAYS=" "+day+" day";}
if (day>1) {DAYS=" "+day+" days";}
else {DAYS="";}
if (mon==1) {MONTH=" "+mon+" month";}
else if (mon>1) {MONTH=" "+mon+" months";}
else {MONTH="";}
if (yr==1) {YEAR=" "+yr+" year";}
if (yr>1) {YEAR=" "+yr+" years";}
else {YEAR="";}
MsgPlus.AddTimer("Timer",10000);
Messenger.MyPersonalMessage="I've been connected for"+YEAR+MONTH+DAYS+HRS+MINS+SECONDS;
}


function Initialize() {
try {seconds = parseInt(shell.RegRead(regPath+"Seconds"));} catch(err) {seconds=0;}
MsgPlus.AddTimer("Timer",10000);
}

and i get this in debug

code:
Script is starting
Script is now loaded and ready
Function called: OnEvent_Initialize
Function called: OnEvent_Timer
Error: 'shell' is undefined.
       Line: 25. Code: -2146823279.
Function OnEvent_Timer returned an error. Code: -2147352567

RE: Online time by KnRd_WC on 08-24-2006 at 05:21 PM

Are you on Win XP ?? Because a friend had the same (no, it was with : new ActiveXObject('UserAccounts.CommonDialog')) problem, and he use Vista Beta 2...


RE: Online time by skyserpent on 08-24-2006 at 05:23 PM

i am on XP


RE: Online time by KnRd_WC on 08-24-2006 at 05:29 PM

Wow, I'm sorry, but I can't help you.... :( That's really strange.... This script works fine for me....

Sorry.......


RE: Online time by skyserpent on 08-24-2006 at 05:30 PM

:(


RE: Online time by Err0r on 08-24-2006 at 06:22 PM

Yay. I tested it. And it worked :D Thank you very much :)


RE: Online time by KnRd_WC on 08-24-2006 at 06:29 PM

No problem, it was a pleasure ;)
:cownana: