What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » WLM Plus! Help » Anyway to automatically set AWAY when computer is lock?

Pages: (3): « First « 1 2 [ 3 ] Last »
Anyway to automatically set AWAY when computer is lock?
Author: Message:
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Anyway to automatically set AWAY when computer is lock?
This works.

js code:
var bIsDesktopLocked = isDesktopLocked();
var nPreStatus = 0;

function OnEvent_Initialize() {
    if (Messenger.MyStatus < STATUS_INVISIBLE) return false;
   
    MsgPlus.AddTimer('isDesktopLocked()', 100);
}

function OnEvent_SigninReady() {
    OnEvent_Initialize();
}

function OnEvent_Timer(sTimerId) {
    if(Messenger.MyStatus !== STATUS_INVISIBLE) {
        var b = isDesktopLocked();
        var n = Messenger.MyStatus;
        if(b !== bIsDesktopLocked) {
            if(Messenger.MyStatus !== STATUS_IDLE || Messenger.MyStatus !== nPreStatus) {
                Messenger.MyStatus = (b ? STATUS_IDLE : nPreStatus);
                nPreStatus = n;
                bIsDesktopLocked = b;
            }
        }
    }
    MsgPlus.AddTimer(sTimerId, 100);
}

function isDesktopLocked() {
    var DESKTOP_SWITCHDESKTOP = 0x100;
   
    var p_lngHwnd = Interop.Call('user32', 'OpenDesktopW', 'Default', 0, false, DESKTOP_SWITCHDESKTOP);
    if(p_lngHwnd !== 0)
        var p_lngRtn = Interop.Call('user32', 'SwitchDesktop', p_lngHwnd);
   
    Interop.Call('user32', 'CloseDesktop', p_lngHwnd);
    return p_lngRtn === 0;
}

Interface will come at a later date. If you want your status to be set to Away instead of Idle (which makes more sense) change STATUS_IDLE to STATUS_AWAY.
10-01-2010 12:45 AM
Profile E-Mail PM Find Quote Report
Bryan84
Junior Member
**


Posts: 62
40 / Male / Flag
Joined: Aug 2006
O.P. RE: Anyway to automatically set AWAY when computer is lock?
Cool! Will be trying it now! :D
[Image: signature.gif]
10-01-2010 12:51 AM
Profile E-Mail PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Anyway to automatically set AWAY when computer is lock?
If your status if Appear Offline nothing will happen to prevent your status from changing.
10-01-2010 12:59 AM
Profile E-Mail PM Find Quote Report
Bryan84
Junior Member
**


Posts: 62
40 / Male / Flag
Joined: Aug 2006
O.P. RE: Anyway to automatically set AWAY when computer is lock?
So if my computer is left UNlock, does the script constantly run to check if my computer is lock? Because if so, I felt it might be use some CPU resources to constantly checking right? If I am wrong, then I am. :P
[Image: signature.gif]
10-01-2010 01:04 AM
Profile E-Mail PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Anyway to automatically set AWAY when computer is lock?
quote:
Originally posted by Bryan84
So if my computer is left UNlock, does the script constantly run to check if my computer is lock? Because if so, I felt it might be use some CPU resources to constantly checking right? If I am wrong, then I am. :P
It does constantly run but it isn't going to put a strain on your CPU at all. You won't even notice it.
10-01-2010 01:07 AM
Profile E-Mail PM Find Quote Report
Bryan84
Junior Member
**


Posts: 62
40 / Male / Flag
Joined: Aug 2006
O.P. RE: Anyway to automatically set AWAY when computer is lock?
Oh okay then! :D So the request of this function by me, ermm no one requested it before? :o
When I lock, surely it goes to away mode. But sometimes when I unlock my computer, its only working sometimes to change my status back ONLINE. Not always.

-edit- okay, in fact it's most of the time, when i unlock, it doesn't change back to ONLINE.
[Image: signature.gif]
10-01-2010 01:15 AM
Profile E-Mail PM Web Find Quote Report
Bryan84
Junior Member
**


Posts: 62
40 / Male / Flag
Joined: Aug 2006
O.P. RE: Anyway to automatically set AWAY when computer is lock?
Any updates to the script? :D
[Image: signature.gif]
10-09-2010 06:31 AM
Profile E-Mail PM Web Find Quote Report
Pages: (3): « First « 1 2 [ 3 ] 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