Umm... theres another problem now.
The actual script I've made (based on the original reply there):
jscript code:
var fsObj = new ActiveXObject("Scripting.FileSystemObject");
var statuschanged = false;
function OnEvent_Initialize(MessengerStart)
{
Old_Status = 0;
isGone = false;
addTimer();
}
function addTimer()
{
MsgPlus.AddTimer("Lock",10000);
}
function OnEvent_Uninitialize(MessengerExit)
{
}
function ReadLineFromFile (file, line)
{
var fileObj = fsObj.OpenTextFile(MsgPlus.ScriptFilesPath + '\\' + file, 1);
var lineResult = fileObj.ReadAll();
lineResult = lineResult.split('\r\n');
fileObj.Close();
return lineResult[line];
}
function OverwriteFile (file, content) {
var fileObj = fsObj.OpenTextFile(MsgPlus.ScriptFilesPath + '\\' + file, 2, 0);
fileObj.Write(content);
fileObj.Close();
}
function OnEvent_Timer(timerID){
if(timerID == "Lock")
{
if (ReadLineFromFile('lockstatus.ini', 0) == "locked")
{
if (Messenger.MyStatus == STATUS_INVISIBLE)
{
addTimer();
return;
}
Old_Status = Messenger.MyStatus;
Messenger.MyStatus = STATUS_AWAY;
isGone = true;
}
if (ReadLineFromFile('lockstatus.ini', 0) == "unlocked")
{
if (Messenger.MyStatus == STATUS_INVISIBLE)
{
addTimer();
return;
}
Messenger.MyStatus = Old_Status;
isGone = true;
OverwriteFile('lockstatus.ini', 'off');
}
}
addTimer();
}
The function: the script does exactly the job what it has to (on timer event it reads a file, if it's content is
locked, the WLM changes its state to "Away", and if the file's content is
unlocked the WLM script changes the state to the original (what it was before), and writes
off to the file (lockstatus.ini).
The problem: After some time (sometimes at login to WLM), the script stops running with the following error(s):
...
Calling function: OnEvent_Initialize
Error: unknown (code: -2147418113)
File: Lock That PC Script.js. Line: 61.
The Line #61 is:
jscript code:
Messenger.MyStatus = Old_Status;
What may be the problem?
Please help me to solve it!
Anyway I don't really know how to use timers.
As I know, if I want timer to run, I have to call the addTimer() function again and again in the code. Am I right?