CallerID using VMCController

Sep 8, 2009 at 12:01 AM


I was looking for a Media Center-compatible tool for reporting Caller ID, but kept running in to limitations with the current solutions- must run as the logged in user, requires Outlook, etc. So after some tinkering I came up with a script-and-XML-based solution which uses the brilliant VMCController to do its job. I hope others find this useful, and I'm providing it here free for noncommercial use. The script (CallerID.vbs) is pasted below. It is designed to run on the media center PC itself.

The script depends on the MSCOMM control, which I installed using this guide:

Usage: cscript CallerID.vbs <Com Port Number> <Path to config XML> <VMCController Extender Ports>

Example: cscript CallerID.vbs 4 \\server\software\VMCController\CallerIDs.xml 40512;40513
The XML format for the database file which holds the numbers, display names, and images to display alongside the names, looks like this:
<imagePath>\\server\photos\PHOTOS FINAL\2009\Putnam County Lake House\IMG_2748.jpg</imagePath>
For any numbers not matched, a generic message is shown with no picture.
Here's the script. Enjoy (at your own risk!)
option explicit

'CallerID.vbs (c) James Forrester 2009
'Use at your own risk!

if WScript.Arguments.Count < 3 then
WScript.Echo "Usage: cscript CallerID.vbs <Com Port Number> <Path to config XML> <VMCController Extender Ports>"
WScript.Echo "Example: cscript CallerID.vbs 4 \\server\software\VMCController\CallerIDs.xml 40512;40513"
end if


dim comm

Set comm = CreateObject("MSCOMMLib.MSComm")
comm.Settings = "9600,n,8,1"
comm.CommPort = WScript.Arguments(0)
comm.InputLen = 0
comm.PortOpen = True
comm.Output = "AT#CID=1" & vbCr
WScript.Echo "Opened the serial port, initiated CID"

comm.InBufferCount = 0

dim extender, extenders

extenders = split(WScript.Arguments(2),";")

dim connectDict
dim buffer, number, name, extenderConnection

number = ""
name = ""

buffer = comm.Input
if instr(1,buffer,"NMBR=") > 0 then
'instr = startpos, string, length
number = mid(buffer,instr(1,buffer,"NMBR=")+5,instr(instr(1,buffer,"NMBR=")+5,buffer,chr(13))-(instr(1,buffer,"NMBR=")+5))
WScript.Echo "Number: " & number
end if

if instr(1,buffer,"NAME=") > 0 then
name = mid(buffer,instr(1,buffer,"NAME=")+5,instr(instr(1,buffer,"NAME=")+5,buffer,chr(13))-(instr(1,buffer,"NAME=")+5))
WScript.Echo "Name: " & name
end if

if len(number) > 0 then
set connectDict = CreateObject("Scripting.Dictionary")
for each extender in extenders
connectDict.Add extender,CreateObject("MSXML2.ServerXmlHttp")
dim xd
set xd = CreateObject("MSXML2.DOMDocument")
xd.Load WScript.Arguments(1)

dim callerNode
set callerNode = xd.SelectSingleNode("/xml/caller[number='" & number & "']")

'WScript.Echo "CallerNode:" & callerNode.xml

dim xh, url
'set xh = CreateObject("MSXML2.XmlHttp")

if not(callerNode is nothing) then
for each extender in connectDict.Keys
set xh = connectDict.Item(extender)
'on error resume next
url = "http://localhost:" & extender & "/msgboxrich ""Incoming Call"" """ & callerNode.selectSingleNode("displayName").Text & " (" & number & ")"" " & DISPLAY_DURATION_SECONDS & " ""OK"" ""nonmodal"" """ & callerNode.selectSingleNode("imagePath").Text & """"
WScript.Echo "Caller found, invoking: " & url
xh.Open "GET",url,true
for each extender in connectDict.Keys
set xh = connectDict.Item(extender)
'on error resume next
url = "http://localhost:" & extender & "/msgbox ""Incoming Call"" """ & name & " (" & number & ")"" " & DISPLAY_DURATION_SECONDS
WScript.Echo "Caller NOT found, invoking: " & url
xh.Open "GET",url,true
end if

WScript.Sleep (DISPLAY_DURATION_SECONDS -1) * 1000
WScript.Echo "Waiting for the next call..."
end if

WScript.Sleep 1000

comm.PortOpen = False
Set comm = Nothing


Jan 12, 2010 at 8:58 PM

I installed this on my Windows 7 MCE computer last night and it worked great! I had been using Vista Caller ID but the MCE plugin would crash on a regular basis and required Outlook integration for caller id images. Your script is nice and lean and works well.

Thanks for the script!

Apr 22, 2010 at 2:59 PM

Thank you jamesf for pointing me in the right direction. This truly is a great little script. It does take a fair amount of work to get running on an x64 platform, though.

First you have to get the mscomm32.ocx registered. From an elevated command prompt, copy the ocx to c:\windows\syswow64 then register with the following:

regsvr32 c:\windows\syswow64\mscomm32.ocx

You will need to run the script from a 32bit command prompt. Create a batch file with the following: (Adjust to your liking)

c:\windows\syswow64\cmd.exe /c "cscript CallerID.vbs 4 \\server\software\VMCController\CallerIDs.xml 40512;40513"

If you get an error about a license, read everything regarding the license on this page


After I sorted all that out, I put a shortcut to the batch file in my startup, set it to start minimized and it just works.