What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Request] Idle Lock

Pages: (2): « First « 1 [ 2 ] Last »
[Request] Idle Lock
Author: Message:
foaly
Senior Member
****

Avatar

Posts: 718
Reputation: 20
37 / Male / Flag
Joined: Jul 2006
RE: [Request] Idle Lock
quote:
Originally posted by Plik
Why not just detect when WLM changes to the idle status and lock messenger then, it would be a lot easy, and make more sense (Smilie)

that is what I was wondering...
12-18-2006 03:59 PM
Profile E-Mail PM Find Quote Report
markee
Veteran Member
*****

Avatar

Posts: 1621
Reputation: 50
35 / Male / Flag
Joined: Jan 2006
RE: RE: [Request] Idle Lock
quote:
Originally posted by Plik
quote:
Originally posted by markee
Attached is the script.  Unfortunately I cannot detect viewing of messenger or when you are typing in a window so there are problems with that.  To overcome this I suggest you use a larger time before it locks.
Why reinvent the wheel?

Why not just detect when WLM changes to the idle status and lock messenger then, it would be a lot easy, and make more sense :P
Which, incidently seams to be done here -> [Release] Idle Security


This would require me to turn on "show me as..." in the WLM preferences :tongue:  Though I recommend everyone use this rather than my script as it will be more reliable.
[Image: markee.png]
12-18-2006 04:02 PM
Profile PM Find Quote Report
ins4ne
Veteran Member
*****

Avatar
...

Posts: 1015
Reputation: 38
36 / Male / Flag
Joined: Apr 2006
Status: Away
RE: [Request] Idle Lock
What about the menu that doesn't appear? 8-)
[Image: b5c5bb366c94ba43283cc13901380e3e.png]
12-18-2006 04:04 PM
Profile PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: RE: [Request] Idle Lock
quote:
Originally posted by markee
Thanks to NanaFreak yet again for the interface too.
The tooltips of the OK and Cancel button are not entirly correct.

for the OK button it should be: "Save settings and close the window" instead of just "Save settings" since that is for an Apply button.

for the Cancel button it should be "Discard the settings and close the window" since "Don't save settings" doesn't say if you're going to close the window too and can also be interpreted as the new made settings will be used but not saved.

;)

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

comments on the script (BUGS, improvements, etc):

1)
code:
try{
    var idle = new ActiveXObject("WScript.Shell").RegRead(MsgPlus.ScriptRegPath+Messenger.MyUserId);
}catch( e ){
    var idle = "";
}
Will _always_ fail because Messenger.MyUserId is _always_ undefined here, unless the script is restarted when the user is signed in (aka: never, unless the user has signed in while he modified something in the script and re-saved it, or when the script is enabled for the first time).

Thus, never use such code in the global scope of the script. Instead put all this in the OnEvent_Signin() event.


2)
code:
MsgPlus.CancelTimer(Messenger.MyUserId);
MsgPlus.AddTimer(Messenger.MyUserId,idle);
If you're going to add/start a timer you do not need to cancel it first. Any timer you re-create will be reset already.

3)
code:
function OnEvent_Timer(ID){
    if(ID==Messenger.MyUserId){
        MsgPlus.LockMessenger(true)
    }
}
This indeed takes in account that the user can sign out and another user signing in when the timers are still running. BUT, you also have:
code:
function OnEvent_Signout( M ){
    MsgPlus.CancelTimer(Messenger.MyUserId);
}
which makes that one of the two is useless (that is: the check in
OnEvent_Timer or the whole OnEvent_Signout event).

In other scripts I would recommend to remove the OnEvent_Signout event and keep the check in OnEvent_Timer. Because if you do that, a user who temporarly signed out, to let someone else on MSN, can afterwards still sign in and the timers of his will still be running for him.
But for this particular script I would remove the check in OnEvent_Timer, since the timer ID will always be the one of the user who set it since you remove the timer in the signout event.

4)
code:
if (/^\/idlelock\s*(.*)$/i.exec(Mess) != null){
If you aren't going to use parameters or whatever, you don't need to check and catch them using a regular expression, simply use:
code:
if (Mess.toLowerCase() === "/idlelock"){
which doesn't need the resources of a regular expression.

Or if you still want to use a regular expression and/or also react on the command when the user has typed something after it, simply remove the parenthesis "(" and ")" (and "$" is also not needed, since you already use ".*").

5)
code:
function OnEvent_MenuClicked(ID,Loc,Orig){
    MsgPlus.CancelTimer(Messenger.MyUserId);
    if(ID=="Pref"){
        var Wnd = MsgPlus.CreateWnd("UI.xml","WndConfig");
        Wnd.SetControlText("EdtMin",Math.floor(idle/60000));
        Wnd.SetControlText("EdtSec",Math.floor(idle%60000/1000));
    }else{
        MsgPlus.AddTimer(Messenger.MyUserId,idle);
    }
}
Cancelling the timer here will produce two bugs/unwanted behaviour:
The messenger will not be locked when the user has openend the preferences and forgot about it (and went to the toilet for 30 minutes :p). And when the user discards the preferences and closes the window, messenger will not be locked anymore after a while.

Second, the 'else' part is useless since there isn't another menu item.

6)
code:
function OnWndConfigEvent_Destroyed(Wnd,C){
    notidle();
}
function OnEvent_Initialize( M ){
    notidle();
}
....
With stuff like this you don't need those parameters, so you might as well just write
code:
function OnWndConfigEvent_Destroyed(){
....
Goes for the rest of those events too.

7)
code:
function OnEvent_ChatWndCreated(Wnd){
    notidle();
}
Remove this event, since a chat window will also be created when a contact messages you. When this happens, the timer must not be cancelled since someone can still message the user while he is away. When that happens, messenger may never go into lock as long as contacts start messaging (Idle means no user interaction, not no interaction at all).
PS: you have this event three times in your script by the way.

Same goes for the events OnEvent_SigninReady() and OnEvent_Initialize because Messenger can signout the user at any time and sign him back in automatically without any user interaction.

On the opposite, there is a notidle() mssing in the OnEvent_MenuClicked() event, since only a user interaction can click on a menu. So replace the cancelling of the timer (see point 5) with notidle().

8)
code:
function OnEvent_MessengerUnlock(Wnd){
    MsgPlus.AddTimer(Messenger.MyUserId,idle);
}
This should contain a notidle() instead (thus with the check on the variable 'idle').



Though, as you said also, this is not a good way to detect being 'idle' as a whole. It has many flaws (not speaking about the above bugs, but about limitations you can't do anything about it by using such a script). Also, what is not implemented is unlocking messenger when the user starts interacting again (major bug too). To overcome all this you should indeed just detect a status change to and from 'Idle' (also because it is way more consistant with the normal flow of things).

;)

This post was edited on 12-18-2006 at 07:38 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
12-18-2006 06:39 PM
Profile PM Find Quote Report
ins4ne
Veteran Member
*****

Avatar
...

Posts: 1015
Reputation: 38
36 / Male / Flag
Joined: Apr 2006
Status: Away
RE: [Request] Idle Lock
Just downloaded the new version and I wanted to brief you that i see the menus now :).
[Image: b5c5bb366c94ba43283cc13901380e3e.png]
12-18-2006 09:24 PM
Profile PM Find Quote Report
Pages: (2): « First « 1 [ 2 ] Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On