public void Export(Deck deck) { if (deck == null) { return; } var hsHandle = User32.FindWindow(null, "Hearthstone"); if (!User32.IsForegroundWindow("Hearthstone")) { //restore window and bring to foreground User32.ShowWindow(hsHandle, SwRestore); User32.SetForegroundWindow(hsHandle); //wait it to actually be in foreground, else the rect might be wrong Thread.Sleep(500); } if (!User32.IsForegroundWindow("Hearthstone")) { MessageBox.Show("Can't find Heartstone window."); return; } User32.Rect hsWindowRect = new User32.Rect(); User32.GetWindowRect(hsHandle, ref hsWindowRect); var height = (hsWindowRect.bottom - hsWindowRect.top); var width = (hsWindowRect.right - hsWindowRect.left); var bounds = Screen.FromHandle(hsHandle).Bounds; bool isFullscreen = bounds.Width == width && bounds.Height == height; foreach (var card in deck.Cards) { AddCardToDeck(card, width, height, hsHandle, isFullscreen); } }