There are various ways, however under the AutomationElement class you are able to inspect the "Current" element and use a combination of ways to determine the element. The following example was taken from another solution See Here
using System.Window.Automation;
private AutomationElement element;
System.Drawing.Point mouse = System.Windows.Forms.Cursor.Position;
this.element = AutomationElement.FromPoint(new System.Windows.Point(mouse.X, mouse.Y));
From here you are able to access the element.Current and extract things such as the Name, ProcessId.
Although this may be something you have already figured out, the following code should help you get the class name of the current UI item, however its NOT a part of the AutomationElement class and is a Win32 hook.
[DllImport("User32.dll")]
public static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
private string GetClassName(IntPtr hWnd)
{
StringBuilder sb = new StringBuilder(256);
this.GetClassName(hWnd, sb, 256);
return sb.ToString();
}
Hope it helps, if only to get you started ;)
RH