Month: March 2014

Adding Custom Commands to Lync Client Menus


We will discuss one of the ways in which the Lync client can be customized by offering contextual options that are specific to your own business needs which is creating custom menu items.

If you want to add your custom Lync application shortcut to the Lync Client you have to use the custom commands. The term “contextual conversations” comes up a lot in working with Lync. As Lync becomes more and more integrated into people’s workflows, it can automate much of this sending and retrieval of appropriate context, saving time and increasing productivity.

Use custom commands embedded in the Lync client UI to launch applications on the Microsoft Windows desktop. these custom commands are menu items added by the developer to the Lync client UI. You can add the custom commands to Lync client menus and pass the SIP Uniform Resource Identifier (URI) of the current user and selected contacts to the application that the custom command starts.

The custom commands that you add can appear on one or more of the following menus:

  • The Tools menu, on the menu bar in the Lync main window
  • The shortcut menu for contacts in the Contacts list
  • The More options menu, in the Conversation window
  • The shortcut menu for people listed in the Conversation window participant list
  • The options menu in a contact card

When you open Lync now, and right-click on a contact, menu items appears as follow:

Context Menu

You can define custom commands for two types of applications:

  • Apply only to the current user and are started on the local computer.
  • Involve additional users, such as an online collaboration program, and must be started on each user’s computer.

The custom command can be invoked in the following ways:

  • Select one or more users, and then choose the custom command.
  • Start a two-party or multiparty conversation, and then choose the custom command.

Adding Custom Command

To add a custom command for an application, add a registry subkey and the registry entries described in this topic.

Registry subkey is the application GUID, added at the following locations:

  • Lync Client 2013, 32-bit OS:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\15.0\Lync\SessionManager\Apps
  • Lync Client 2013, 64-bit OS:
    HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Office\15.0\Lync\SessionManager\Apps
  • Lync Client 2010, 32-bit OS:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Communicator\SessionManager\Apps
  • Lync Client 2010, 64-bit OS:
    HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Communicator\SessionManager\Apps

Registry entries under each GUID subkey, add the entries described as follow

Entry Type Description
Name REG_SZ The name of the application as it appears in the Lync UI.
Path REG_SZ The full path of the application along with parameters, including the default parameters of %user-id% and %contact-id%. The parameters pass a string representing the SIP URI of the user signed in to Lync and the selected contact or contacts to the application launched.
ApplicationType DWORD 0 = Executable, 1 = Protocol.
ApplicationInstallPath REG_SZ The full path of the executable, which is required if ApplicationType is 0.
SessionType DWORD 0 = local session, 1 = two-party session, 2 = multi-party session.
ExtensibleMenu REG_SZ A semicolon-delimited list of places where the command appears. Possible values include MainWindowActions, MainWindowRightClick, ConversationWindowActions, ConversationWindowRightClick, and ContactCardMenu. If ExtensibleMenu is not defined, the default values of MainWindowRightClick and ConversationWindowActions are used.

Examples show usage for HTML and .exe paths:

c:\\ext_menu.exe /userId="%user-id%" /contactId="%contact-id%"
http://localhost/Code4Lync/Test.html?userId=%user-id%;contactId=%contact-id%

See Also the following Registry Editor (.reg) files as examples:

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\15.0\Lync\SessionManager\Apps\{3E0352E8-21F3-4E00-AA46-2ADA7085C9AD}]
"Name"="Code 4 Lync Custom Application"
"ApplicationType"=dword:00000000
"ApplicationInstallPath"="C:\\YourApp.exe"
"Path"="C:\\YourApp.exe /userId=%user-id% /contactId=%contact-id%"
"SessionType"=dword:00000000
"ExtensibleMenu"="ConversationWindowRightClick;ContactCardMenu;MainWindowRightClick"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\15.0\Lync\SessionManager\Apps\{96DC330B-0A57-4A26-963B-75A109CD3C30}]
"Name"="Code 4 Lync Custom Application"
"Path"="C:\\Program Files (x86)\\YourApplication\\YourApp.exe %param1%"
"ToolTip"="tooltip text"
"ApplicationType"=dword:00000000
"SessionType"=dword:00000002
"Extensiblemenu"="MainWindowActions;MainWindowRightClick;ConversationWindowActions;ConversationWindowContextual;ConversationWindowRightClick;ConversationWindowButton"

Using Custom Command

The following table describes how to launch an application with a given ExtensibleMenu value.

ExtensibleMenu value Action
MainWindowActions In the upper-right corner of the Lync 2013 conversation window, click the Show menu button, point to Tools, and then click the custom command.
MainWindowRightClick In the conversation window, right-click a contact in the Contact List or Search Results pane, and then click the custom command.
ConversationWindowActions In the lower-right corner of the conversation window, click the More options ellipse, point to Actions, and then click the custom command.
ContactCardMenu Click the custom command on the contact card Options menu.

To test your custom menu by retrieve the %user-id% and %contact-id% arguments, add C# code to the application launched by the custom command.

static void Main(string[] args)
{
  if (null == args || args.Length == 0) Console.WriteLine("No args");
  else
  {
    foreach (string arg in args)
    {
      Console.WriteLine("Arg: " + arg);
    }
  }
  Console.ReadLine();
}

Removing Custom Command

Removing the GUID subkey removes the appropriate custom commands from the Lync UI.

Advertisements