Monday, October 03, 2011

Office Communicator 2007 - send message

It would have been nice if there was a command line way of sending message from office communicator. Googled and did not found anything. Finally created a fragile scritp using WSHShell . It is fragile but it works and saves time for me.

option explicit

' Global variable to hold the initials and name mapping.
' Commandline may have initials in place of the name.
dim Names
Set Names = CreateObject("Scripting.Dictionary")
Names.Add "C1", "Contact1"
Names.Add "C2", "Contact2"
Names.Add "C3", "Contact3"

' Global variable used by mySendKeys function.
dim Wsh
set Wsh = Wscript.CreateObject("Wscript.Shell")

if (Wscript.Arguments.Count < 1) Then
Wscript.Echo "Usage: m "
Wscript.Quit(1)
End if

dim name
name = UCASE(Wscript.Arguments(0))
if (Names.Exists(name)) then
name = Names.item(name)
end if

'Wscript.echo name

Wsh.Run "communicator" ' Run communicator
Wscript.Sleep 500 ' Give time for communicator to open.
mySendKeys "{TAB}" ' TAB
mySendKeys "{DOWN}" ' Down Arrow
mySendKeys name ' Search for the contact in my list.
Wscript.Sleep 500 ' Wait for select to happen.
mySendKeys "{ENTER}" ' Enter
Wscript.Quit(0) ' Success

Function mySendKeys(key)
wsh.AppActivate "Office Communicator"
wsh.SendKeys key
End Function

No comments:

Post a Comment