First of all, code to connect and interact with Skype is from Gabriel Szabo.
We can find complete implementation of classes to use Skype from C# in this article:
CodeProject article by Gabriel Szabo.
Secondly, we have to know how to set our "mood" in Skype. This is easily done consulting
Skype public API reference at:
Skype API Reference.
What we are interested in is this command:
#abc SET PROFILE MOOD_TEXT Put your current mood here
Next, we have to get data from Visual Studio current window. This is done by the
"
VisualStudioWindowUtils" class. This one basically uses Windows API to get
VS title bar and retrieve project and file data from there, parsing strings. These
are relevant API:
[System.Runtime.InteropServices.DllImport("user32.dll",
CharSet = System.Runtime.InteropServices.CharSet.Auto)]
private static extern IntPtr FindWindow(string lpClassName,
string lpWindowName);
[System.Runtime.InteropServices.DllImport("user32.dll",
CharSet = System.Runtime.InteropServices.CharSet.Auto)]
private static extern int GetWindowText(IntPtr hwnd,
string lpString, int cch);
I also added a textbox in main window, so we can have a filter on VS window title,
allowing to pick only desired project if working with many projects at the same
time.
Because we can start as many utilities as we want, application also implement the
Mutex trick to be
Single-Instance.
At last, I would like to always be on the last line of
RichTextBox, to show
last logged event, so I added this code to force scrolling (I've not found another
way of getting this without using PInvoke):
[System.Runtime.InteropServices.DllImport("user32.dll",
CharSet = System.Runtime.InteropServices.CharSet.Auto)]
private static extern Int32 SendMessage(IntPtr hwnd, Int32 wMsg,
Int32 wParam, Int32 lParam);
private void ScrollText(RichTextBox Destination)
{
int SB_BOTTOM = 7;
int WM_VSCROLL = 0x0115;
SendMessage(Destination.Handle, WM_VSCROLL, SB_BOTTOM, 0);
}