コード例 #1
0
        /// <summary>
        /// 抓取前台模式
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GameWindow_Desktop_button_Click(object sender, EventArgs e)
        {
            GlobalObject.GameHandle = new GameHandleClass();
            int   SH = Screen.PrimaryScreen.Bounds.Height; //屏幕分辨率高度
            int   SW = Screen.PrimaryScreen.Bounds.Width;  //屏幕分辨率宽度
            Point xy = new Point();

            using (var bmp = FunctionBitmap.CopyWindow())
            {
                if (FunctionJudge.IsGameInWin(bmp, out xy))
                {
                    GlobalObject.GameHandle                   = new GameHandleClass();
                    GlobalObject.GameHandle.Handle            = IntPtr.Zero;
                    GlobalObject.GameHandle.Mode              = FunctionHandle.MODE.Desktop;
                    GlobalObject.GameHandle.XY                = xy;
                    this.GameWindow_Message_textBox.Text      = "前台模式抓取成功";
                    this.GameWindow_Message_textBox.BackColor = Color.Lime;
                    RefreshGameWindow_pictureBox();
                }
                else
                {
                    GlobalObject.GameHandle = new GameHandleClass();
                    this.GameWindow_Message_textBox.Text      = "前台模式抓取失败";
                    this.GameWindow_Message_textBox.BackColor = Color.Red;
                    RefreshGameWindow_pictureBox();
                }
            }
        }
コード例 #2
0
ファイル: GameHandle.cs プロジェクト: DNoki/NokiKanColle
 /// <summary>
 /// 获取游戏窗口图像(*注意析构图像)
 /// </summary>
 /// <returns>游戏图像</returns>
 public Bitmap GetGameBitmap()
 {
     if (!IsSuccess)
     {
         return(null);
     }
     if (_photo != null)
     {
         _photo?.Dispose(); _photo = null;
     }
     if (_mode == FunctionHandle.MODE.Handle)
     {
         _photo = FunctionBitmap.PrtGameWindow(this);
     }
     else if (_mode == FunctionHandle.MODE.Desktop)
     {
         _photo = FunctionBitmap.CutImage(FunctionBitmap.CopyWindow(), _xy.X, _xy.Y, 800, 480, true);
     }
     else if (_mode == FunctionHandle.MODE.Chorme)
     {
         _photo = FunctionBitmap.CutImage(FunctionBitmap.PrtGameWindow(this), _xy.X, _xy.Y, 800, 480, true);
     }
     else
     {
         return(null);
     }
     return(_photo);
 }