Cookie CSS

Sunday, September 20, 2015

Minimizing a Lync Conversation Window

Let's face it, if you are dealing with multiple simultaneous audio calls, Lync / Skype for Business can make a mess of your screen in a hurry.  Unlike IM modality only windows, you con't get the option to have audio calls in an organized tab format, they seem to appear in random locations all over the screen.



Unlike this mess, when you minimize an audio call you nice need like call monitor that really can do everything you need.



So how can we auto minimize these ugly windows using the Lync client SDK?  It's not hard at all.

        [DllImport("user32.dll")]
        private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);

First we use the above code to let us run the ShowWindowAsync method that we can pass our window handle to and tell it to minimize that window.  This let's us talk directly to the OS.

Next we need to take advantage of the Automation ability in the LyncClient object by doing something like this.

Automation a = LyncClient.GetAutomation();

Now we find the conversation we want to minimize or build an easy foreach look on the LyncClient.ConversationManager.Conversations objects to burn through them all.

Conversation c;

Once we have our conversation we use the automation to get the window, then the window handle.

ConversationWindow cw = a.GetConversationWindow(c);

IntPtr myh = cw.Handle;

Then finally we call our user32.dll we declared at the top to tell Windows to minimize that conversation window.

ShowWindowAsync(myh, 2);

That will conclude this weeks blog post.  If you have any questions hit me up on twitter.

Doug Routledge, C# Lync, Skype for Business, SQL, Exchange, UC Developer  BridgeOC
Twitter - @droutledge @ndbridge