//窗口句柄相关成员 /// <summary> /// 自动后台模式 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GameWindow_AutoHandle_button_Click(object sender, EventArgs e) { //自动查找游戏句柄 int SH = Screen.PrimaryScreen.Bounds.Height; //屏幕分辨率高度 int SW = Screen.PrimaryScreen.Bounds.Width; //屏幕分辨率宽度 using (GameHandleClass SeekHandle = new GameHandleClass()) { SeekHandle.Mode = FunctionHandle.MODE.Handle; Point XY = new Point(0, 0); do { SeekHandle.Handle = FunctionHandle.WindowFromPoint(XY); if (XY.X > SW) { XY.X = 0; XY.Y += 100; } else { XY.X += 100; } if ((XY.X > SW) && (XY.Y > SH)) { this.GameWindow_Message_textBox.Text = "自动后台模式抓取失败╭இɷஇ╮"; this.GameWindow_Message_textBox.BackColor = Color.Red; GlobalObject.GameHandle = new GameHandleClass(); RefreshGameWindow_pictureBox(); return; } } while (!SeekHandle.IsWin_800x480()); GlobalObject.GameHandle = new GameHandleClass(SeekHandle); GlobalObject.GameHandle.Mode = FunctionHandle.MODE.Handle; // 更改模式 RefreshGameWindow_treeView(GlobalObject.GameHandle.Handle); // 刷新树状图 this.GameWindow_Message_textBox.Text = "后台模式抓取成功 句柄:" + GlobalObject.GameHandle.Handle.ToString(); this.GameWindow_Message_textBox.BackColor = Color.Lime; RefreshGameWindow_pictureBox(); } }
/// <summary> /// Chorme后台模式 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GameWindow_Handle_button_MouseCaptureChanged(object sender, EventArgs e) { if (GameWindow_IsHandleClick) { GameWindow_IsHandleClick = false; return; } //手动查找游戏句柄 using (GameHandleClass SeekHandle = new GameHandleClass()) { SeekHandle.Handle = FunctionHandle.GetMouseHandle(); SeekHandle.Mode = FunctionHandle.MODE.Handle; if (SeekHandle.IsWin_800x480()) { GlobalObject.GameHandle = new GameHandleClass(SeekHandle) { Mode = FunctionHandle.MODE.Handle }; RefreshGameWindow_treeView(GlobalObject.GameHandle.Handle); this.GameWindow_Message_textBox.Text = "后台模式抓取成功 句柄:" + GlobalObject.GameHandle.Handle.ToString(); this.GameWindow_Message_textBox.BackColor = Color.Lime; RefreshGameWindow_pictureBox(); return; } else//chorme模式 { SeekHandle.Mode = FunctionHandle.MODE.Handle; Point xy = new Point(); if (FunctionJudge.IsGameInWin(SeekHandle.GetGameBitmap(), out xy)) { GlobalObject.GameHandle = new GameHandleClass(SeekHandle) { Mode = FunctionHandle.MODE.Chorme, XY = xy }; RefreshGameWindow_treeView(GlobalObject.GameHandle.Handle); this.GameWindow_Message_textBox.Text = "后台模式抓取成功 chorme句柄:" + GlobalObject.GameHandle.Handle.ToString(); this.GameWindow_Message_textBox.BackColor = Color.Lime; RefreshGameWindow_pictureBox(); } else { // 尝试根父句柄的抓取 SeekHandle.Handle = FunctionHandle.GetTopFatherHandle(SeekHandle.Handle); SeekHandle.Mode = FunctionHandle.MODE.Handle; if (FunctionJudge.IsGameInWin(SeekHandle.GetGameBitmap(), out xy)) { GlobalObject.GameHandle = new GameHandleClass(SeekHandle) { Mode = FunctionHandle.MODE.Chorme, XY = xy }; RefreshGameWindow_treeView(GlobalObject.GameHandle.Handle); this.GameWindow_Message_textBox.Text = "后台模式抓取成功 chorme句柄:" + GlobalObject.GameHandle.Handle.ToString(); this.GameWindow_Message_textBox.BackColor = Color.Lime; RefreshGameWindow_pictureBox(); } else { RefreshGameWindow_treeView(SeekHandle.Handle); this.GameWindow_Message_textBox.Text = "后台模式抓取失败 句柄:" + SeekHandle.Handle.ToString(); this.GameWindow_Message_textBox.BackColor = Color.Red; GlobalObject.GameHandle = new GameHandleClass(); RefreshGameWindow_pictureBox(); } } } } }