Exemplo n.º 1
0
        private async void DispatcherTimer_TickAsync(object sender, EventArgs e)
        {
            try
            {
                IntPtr handler = WindowsUtilities.GetActiveWindowHandler();

                if (gameWindowHandler == IntPtr.MaxValue)
                {
                    var targetTitle = WindowsUtilities.GetWindowTitle(handler)?.Trim();
                    if (targetTitle?.Contains(gameConfig.WindowTitle) == true && targetTitle != TitleText)
                    {
                        gameWindowHandler = handler;
                        StatusBlock.Text  = "Game window detected";
                    }
                }

                if (handler == gameWindowHandler && WindowState == WindowState.Normal)
                {
                    using Bitmap gameBm = CurrentGameBitmap();

                    if (await TranslateAndUpdateTextBlocksAsync(await p.OCRChoicesAsync(gameBm)))
                    {
                        StatusBlock.Text = "Choices";
                        return;
                    }
                    else if (await TranslateAndUpdateTextBlocksAsync(await p.OCRStoryDialogueAsync(gameBm)))
                    {
                        StatusBlock.Text = "Story";
                        return;
                    }
                }
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc);
            }
        }