Taskbar.GetInfos - screenshakes/Desktopia GitHub Wiki

Returns the position and rectangle of the taskbar.

public static TaskbarInfos GetInfos()
{
    var abd = new APPBARDATA();
    abd.cbSize = Marshal.SizeOf(typeof(APPBARDATA));

    var result = SHAppBarMessage(ABM_GETTASKBARPOS, ref abd);

    if (result != IntPtr.Zero)
    {
        return new TaskbarInfos
        {
            Position = (TaskbarPosition) abd.uEdge,
            Rectangle = new Rect(abd.rc.left, abd.rc.top, abd.rc.right - abd.rc.left, abd.rc.bottom - abd.rc.top)
        };
    }
    else
    {
        return new TaskbarInfos() { Position = TaskbarPosition.Unknown };
    }
}