public void UpdatePosition()
        {
            if (!User32.IsForegroundWindow("Hearthstone") && !_needToRefresh)
            {
                _needToRefresh = true;
            }
            else if (_needToRefresh && User32.IsForegroundWindow("Hearthstone"))
            {
                _needToRefresh = false;
                Update(true);
            }

            //hide the overlay depenting on options
            ShowOverlay(!(
                            (_config.HideInBackground && !User32.IsForegroundWindow("Hearthstone")) ||
                            (_config.HideInMenu && _hearthstone.IsInMenu) ||
                            _config.HideOverlay));

            var hsRect = new User32.Rect();

            User32.GetWindowRect(User32.FindWindow(null, "Hearthstone"), ref hsRect);

            //hs window has height 0 if it just launched, screwing things up if the tracker is started before hs is.
            //this prevents that from happening.
            if (hsRect.bottom - hsRect.top == 0)
            {
                return;
            }

            SetRect(hsRect.top, hsRect.left, hsRect.right - hsRect.left, hsRect.bottom - hsRect.top);
            ReSizePosLists();
        }
示例#2
0
        public static bool IsFullscreen(string windowName)
        {
            var hsHandle = User32.FindWindow("UnityWndClass", windowName);

            var hsRect = User32.GetHearthstoneRect(false);

            var bounds = Screen.FromHandle(hsHandle).Bounds;

            return(bounds.Width == hsRect.Width && bounds.Height == hsRect.Height);
        }
示例#3
0
        public void UpdatePosition()
        {
            //hide the overlay depenting on options
            EnableCanvas(!(
                             (_config.HideInBackground && !User32.IsForegroundWindow("Hearthstone")) ||
                             (_config.HideInMenu && _hearthstone.IsInMenu) ||
                             _config.HideOverlay));

            var hsRect = new User32.Rect();

            User32.GetWindowRect(User32.FindWindow(null, "Hearthstone"), ref hsRect);
            SetRect(hsRect.top, hsRect.left, hsRect.right - hsRect.left, hsRect.bottom - hsRect.top);
            ReSizePosLists();
        }
示例#4
0
        public static async Task Export(Deck deck)
        {
            if (deck == null)
            {
                return;
            }

            var hsHandle = User32.FindWindow("UnityWndClass", "Hearthstone");

            if (!User32.IsForegroundWindow("Hearthstone"))
            {
                //restore window and bring to foreground
                User32.ShowWindow(hsHandle, User32.SwRestore);
                User32.SetForegroundWindow(hsHandle);
                //wait it to actually be in foreground, else the rect might be wrong
                await Task.Delay(500);
            }
            if (!User32.IsForegroundWindow("Hearthstone"))
            {
                MessageBox.Show("Can't find Heartstone window.");
                return;
            }

            var hsRect = User32.GetHearthstoneRect(false);
            var bounds = Screen.FromHandle(hsHandle).Bounds;
            var ratio  = (4.0 / 3.0) / ((double)hsRect.Width / hsRect.Height);

            if (Config.Instance.ExportSetDeckName)
            {
                await SetDeckName(deck.Name, ratio, hsRect.Width, hsRect.Height, hsHandle);
            }

            await ClickAllCrystal(ratio, hsRect.Width, hsRect.Height, hsHandle);

            foreach (var card in deck.Cards)
            {
                await AddCardToDeck(card, ratio, hsRect.Width, hsRect.Height, hsHandle);
            }
        }
示例#5
0
        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);
            }
        }