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.