64BIT - The Collection

AutoIT - MS Office Communicator Status Monitoring

With the advent of more "work from home" programs popping up at large organizations all over the world, most communication is now done by instant messaging.  What folks don't realize though, is that tracking their status on an instant messenger like this allows you to infer details around exactly how much time they're spending on their PC while working from home. A status of INACTIVE indicates that the person's client has gone to Away mode due to inactivity on the other side.  That's a big giveaway that the person is not at their PC.  This application allows you to monitor status changes of people on your MS Office Communicator client (2007).

#include <GUIConstants.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <FileConstants.au3>
#include <Date.au3>

 Local $arr[11] ; Make room for elements
 ;Assign some data
 $arr[0]="person1@company.com"
 $arr[1]="person2@company.com"
 $arr[2]="person3@company.com"
 $arr[3]="person4@company.com"
 $arr[4]="person5@company.com"

   


Local $oldStatus[11] ; Make room to store status
$oldStatus[0] = ""
$oldStatus[1] = ""
$oldStatus[2] = ""
$oldStatus[3] = ""
$oldStatus[4] = ""
$oldStatus[5] = ""
$oldStatus[6] = ""
$oldStatus[7] = ""
$oldStatus[8] = ""
$oldStatus[9] = ""
$oldStatus[10] = ""


 ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = "C:\temp\logger.csv"

    ; Open the file for writing (append to the end of a file) and store the handle to a variable.
    Local $hFileOpen = FileOpen($sFilePath, $FO_APPEND)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.")
        Return False
    EndIf


  FileWrite($hFileOpen, @YEAR & "-" & @MON & "-" & @MDAY & "-" & @HOUR & ":" & @MIN & ":" & @SEC & "," & "******  User  ******" &  "," & "Status" & @crlf)
   
While 1

   
_statusIM()
sleep(1000)

Wend
 FileClose($hFileOpen)

Func _statusIM()
      
$oCommunicator = ObjCreate("Communicator.UIAutomation")
For $i = 0 To 10 
   $current = $arr[$i]
   $m = $oCommunicator.GetContact($current, $oCommunicator.MyServiceID)
   $statusName = _GetStatusName($m.Status())
   if $statusName <> $oldStatus[$i] Then 
   FileWrite($hFileOpen, @YEAR & "-" & @MON & "-" & @MDAY & "-" & @HOUR & ":" & @MIN & ":" & @SEC & "," & $current & "," & $statusName & @crlf)
   EndIf
   $oldStatus[$i]=$statusName
Next
EndFunc

func _GetStatusName($var)
Switch $var
  Case 0
   return "UNKNOWN"
  Case 1
   return "OFFLINE"
  Case 2
   return "ONLINE"
  Case 10
   return "BUSY"
  Case 18
   return "INACTIVE"
  Case 34
   return "AWAY"
EndSwitch

EndFunc