views:

18

answers:

2

In an Win/IE environment with the right settings you can fire up a .exe file.

The following code runs fine to fire up Microsoft Lync (the new name for Office Communicator).

...
    <a href="#" onclick="fnShellExecute();">start chat</a>
</body>
</html>
<script type="text/javascript">
    function fnShellExecute()
    {
        var objShell = new ActiveXObject("shell.Application");
        objShell.ShellExecute("communicator.exe", "", "C:\Program Files (x86)\Microsoft Lync", "open", 10);
    }
</script>

But I can't work out the parameters (or if it is possible) to create a shortcut that would open the Lync client with the chat box to another available user open. Basically I know who is available and I want to be able to create (in HTML) a simple link that would open a chat window to that person (outside of WPF or Silverlight or any of the built in controls).

Does anyone know how to adjust this line in the javascript to open a Lync chat window to a specified contact?

objShell.ShellExecute("communicator.exe", "", "C:\Program Files (x86)\Microsoft Lync", "open", 10);

Or if there is another way to open Lync in chat mode via some kind of shortcut?

Thank you in advance.

A: 

Depending on your requirements, the easiest will be to use the existing NameCtrl persona menu - this is the pop-up menu that gets displayed in SharePoint (and other web-based apps like Dynamics CRM) when hovering over a users presence icon. This menu allows you to call the user, start a new conversation etc. You'd need Office installed on the machine you are running on in order for it to work.

As an example, try this on any client machine running Office 2007/2010 and IE. Hover over the "Your Contact" text to see the persona menu:

<script>

var sipUri = "[email protected]";

var nameCtrl = new ActiveXObject('Name.NameCtrl.1');
if (nameCtrl.PresenceEnabled)
{
  nameCtrl.OnStatusChange = onStatusChange;
  nameCtrl.GetStatus(sipUri, "1");
}


function onStatusChange(name, status, id)
{
  // This function is fired when the contacts presence status changes.
  // In a real world solution, you would want to update an image to reflect the users presence
  alert(name + ", " + status + ", " + id);
}

function ShowOOUI()
{
  nameCtrl.ShowOOUI(sipUri, 0, 15, 15);
}

function HideOOUI()
{
  nameCtrl.HideOOUI();
}

</script>

<span onmouseover="ShowOOUI()" onmouseout="HideOOUI()" style="border-style:solid">Your Contact</span>
Paul Nearney
A: 

If the NameCtrl answer doesn't meet your requirements, you could try the Lync SDK. It would be pretty straightforward to create a .NET DLL that uses the Automation API to open a conversation with a given user.

You would then need to expose this via COM to ensure it could be called from JavaScript. Again, pretty straightforward using .NET's COM Interop features.

Paul Nearney