public static AllWindowsLayout GetCurrentLayout() { AllWindowsLayout output = new(); EnumWindows(delegate(IntPtr hWnd, int lParam) { if (!IsWindowVisible(hWnd)) { return(true); } string windowTitle = WindowHooks.GetWindowTitle(hWnd); if (windowTitle is null or "") { return(true); } output.WindowPositions[hWnd] = new WindowLayout { Position = WindowHooks.GetWindowRect(hWnd), WindowToPrecede = WindowHooks.GetNextWindow(hWnd) }; return(true); }, 0); return(output); }
public static void SetCurrentLayout(AllWindowsLayout newLayout) { foreach (var kvp in newLayout.WindowPositions) { WindowHooks.SetWindowLayout(kvp.Key, kvp.Value.Position, kvp.Value.WindowToPrecede); } WindowHooks.WindowArrangementManuallyChanged(); }