Shoutbox

Anyway to automatically set AWAY when computer is lock? - 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: WLM Plus! Help (/forumdisplay.php?fid=12)
+----- Thread: Anyway to automatically set AWAY when computer is lock? (/showthread.php?tid=95516)

Anyway to automatically set AWAY when computer is lock? by Bryan84 on 09-28-2010 at 07:51 AM

Any hotkey to Set Away mode?

-edit- I decided to change the topic title to reflect more to what I need. (read on below)


RE: Any hotkey to Set Away? by matty on 09-28-2010 at 11:27 AM

What hotkey would you like to use for an Away status?


RE: Any hotkey to Set Away? by djdannyp on 09-28-2010 at 04:48 PM

You can type "/away" in a conversation window and it will set you to away


RE: Any hotkey to Set Away? by matty on 09-28-2010 at 05:37 PM

I think the OP is looking for something like Ctrl+Shift+A and it will set the status to away.


RE: Any hotkey to Set Away? by CookieRevised on 09-28-2010 at 07:09 PM

You could do it, without a script, by using the Personalized Statusses in Plus!.

Though this also requires that you at least set a name tag or a personal message or an auto-responder message.

But there is a trick here...

If you set the command /away as the auto-responder message, you actually send nothing to the chat window as an auto-response when someone messages you... That is: you actually set your status to away, but since it is already away, nothing will happen!

Bottom line: this can perfectly be done by using the Personalized Status feature in Plus!, like so:
Plus! > Preferences & Options > Customize! > Personalized Status > Add...
And then something like this:
[Image: attachment.php?pid=1001022]


RE: RE: Any hotkey to Set Away? by Bryan84 on 09-29-2010 at 08:53 AM

quote:
Originally posted by matty
I think the OP is looking for something like Ctrl+Shift+A and it will set the status to away.

Yeah you are correct. Because often I have to WinKey + L to lock my workstation as I step away from my desk. So when I lock my computer, I would like my WLM to auto set away for me. :)

yeah Ctrl + Alt + L seems okay to what I want to do. Thanks. If only Winkey+L works too... so locking the computer and setting away is done with just one action =D
RE: Any hotkey to Set Away? by djdannyp on 09-29-2010 at 11:30 AM

You could always set your WLM to a short 'Idle' time, that way, when you lock your computer, it can set itself to away within 1/2 minutes of inactivity?

Again, it's perhaps not ideal, but it will save you needing two shortcut keys?


RE: Any hotkey to Set Away? by matty on 09-29-2010 at 01:31 PM

Well I could easily create a script to set the status to Idle when you lock your computer. That is simple.

Something like this could work (untested by the way):

js code:
var bIsDesktopLocked;
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) {
    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;
        }
    }
    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;
}

RE: Any hotkey to Set Away? by Spunky on 09-29-2010 at 02:28 PM

One of my scripts allows you to do this and is customizable :D

EDIT: If I remember correctly, the Windows WIN+L shortcut to lock the workstation takes priority over any over shortcuts so it may not work to set it to that. You could however set it to WIN+K and do the two shortcuts one after another


RE: Any hotkey to Set Away? by matty on 09-29-2010 at 03:55 PM

quote:
Originally posted by Spunky
One of my scripts allows you to do this and is customizable :D

EDIT: If I remember correctly, the Windows WIN+L shortcut to lock the workstation takes priority over any over shortcuts so it may not work to set it to that. You could however set it to WIN+K and do the two shortcuts one after another
I think you misunderstood my code. It just monitors for a locked desktop not the Win+L shortcut key :)
RE: Any hotkey to Set Away? by Spunky on 09-29-2010 at 08:02 PM

quote:
Originally posted by matty
quote:
Originally posted by Spunky
One of my scripts allows you to do this and is customizable :D

EDIT: If I remember correctly, the Windows WIN+L shortcut to lock the workstation takes priority over any over shortcuts so it may not work to set it to that. You could however set it to WIN+K and do the two shortcuts one after another
I think you misunderstood my code. It just monitors for a locked desktop not the Win+L shortcut key :)

TBH, I didn't really read the code, but it wasn't referring to that anyway. I was just referring to the process of setting a hotkey to something that has already been assigned a windows function.

Also, is
quote:
0. false

a mistake? I've not seen it like that before :p
RE: Any hotkey to Set Away? by matty on 09-29-2010 at 09:41 PM

quote:
Originally posted by Spunky
a mistake? I've not seen it like that before :p
It is new hybrid code! Only 128bit processors can run it :P
RE: RE: Any hotkey to Set Away? by Bryan84 on 09-30-2010 at 02:52 AM

quote:
Originally posted by matty
Well I could easily create a script to set the status to Idle when you lock your computer. That is simple.

Something like this could work (untested by the way):
js code:
var bIsDesktopLocked;
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) {
    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;
        }
    }
    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;
}


Thanks! Exactly best of what I wanted! :D

There is a line that I can change if I choose to set as BUSY instead of AWAY? :D
RE: Any hotkey to Set Away? by matty on 09-30-2010 at 03:12 AM

quote:
Originally posted by Bryan84
quote:
Originally posted by matty
Well I could easily create a script to set the status to Idle when you lock your computer. That is simple.

Something like this could work (untested by the way):
js code:
var bIsDesktopLocked;
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) {
    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;
        }
    }
    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;
}


Thanks! Exactly best of what I wanted! :D

There is a line that I can change if I choose to set as BUSY instead of AWAY? :D
Well currently it would set you to idle if you lock your computer. You can change both the STATUS_IDLE with any of the following
RE: Any hotkey to Set Away? by CookieRevised on 09-30-2010 at 03:16 AM

I haven't tested the code either, but by the looks of it it isn't going to work (or I need some more sleep though... quite possible too)...

bIsDesktopLocked isn't set anywhere, yet is used to be compared with b which is the result of the isDesktopLocked() function.

And what after the desktop is unlocked? It doesn't seem to switch the status back, even if bIsDesktopLocked was set to the previous state of b (unless it was never intended to do, then I'll shut up).

And when the status is Appearing Offline, locking the workstation shouldn't set the status to Idle (or Away).


RE: Any hotkey to Set Away? by Bryan84 on 09-30-2010 at 04:27 AM

I applied that script and something is wrong. My message icon, is flicking between ONLINE and AWAY like CONSTANTLY. LOL. Like it's ON OFF ON OFF ON OFF in seconds!

-edit- then again seems okay now. Weird. So anyway to set the status back to ONLINE automatically when my computer is unlock?


RE: Anyway to automatically set AWAY when computer is lock? by matty on 09-30-2010 at 12:25 PM

Yeah Cookie, I realized late last night that bIsDesktopLocked wasn't being set. Like I said I didn't test the code. I will try and get to it tonight to see.

As for the constant change in status that is weird, I will have to have a look.


RE: RE: Anyway to automatically set AWAY when computer is lock? by Bryan84 on 09-30-2010 at 01:01 PM

quote:
Originally posted by matty
Yeah Cookie, I realized late last night that bIsDesktopLocked wasn't being set. Like I said I didn't test the code. I will try and get to it tonight to see.

As for the constant change in status that is weird, I will have to have a look.

Alright. That on and off problem does not always happen. Just sometimes. Maybe you should make part where it will auto set back to Online when computer is Unlock?
RE: Anyway to automatically set AWAY when computer is lock? by matty on 09-30-2010 at 01:07 PM

I will add an interface around it where you can select the status for the 2 scenarios.


RE: Anyway to automatically set AWAY when computer is lock? by Bryan84 on 09-30-2010 at 01:11 PM

Cool alright! :) Sounds nice!


RE: Anyway to automatically set AWAY when computer is lock? by matty on 10-01-2010 at 12:45 AM

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.
RE: Anyway to automatically set AWAY when computer is lock? by Bryan84 on 10-01-2010 at 12:51 AM

Cool! Will be trying it now! :D


RE: Anyway to automatically set AWAY when computer is lock? by matty on 10-01-2010 at 12:59 AM

If your status if Appear Offline nothing will happen to prevent your status from changing.


RE: Anyway to automatically set AWAY when computer is lock? by Bryan84 on 10-01-2010 at 01:04 AM

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


RE: Anyway to automatically set AWAY when computer is lock? by matty on 10-01-2010 at 01:07 AM

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.
RE: Anyway to automatically set AWAY when computer is lock? by Bryan84 on 10-01-2010 at 01:15 AM

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.
RE: Anyway to automatically set AWAY when computer is lock? by Bryan84 on 10-09-2010 at 06:31 AM

Any updates to the script? :D