private void ManualSet_MouseUp(object sender, MouseEventArgs e) { manual.Enabled = false; ActionHandle getsize = new ActionHandle(); Gamewidth = getsize.Getwidth_height(GamehWnd)[0]; //窗口的宽度 Gameheight = getsize.Getwidth_height(GamehWnd)[1]; //窗口的高度 MessageBox.Show("句柄为" + GamehWnd + " " + "窗口大小为" + Gamewidth + "x" + Gameheight); if (Gamewidth != 800 || Gameheight != 480) { MessageBox.Show("窗口大小不正确 请重新自动/手动获取句柄 POI请使用自动模式"); GamehWnd = IntPtr.Zero; Gamewidth = 0; Gameheight = 0; label22.Text = "未设定"; label62.Text = "未设定"; logbox1.Items.Insert("窗口大小不正确 请重新自动/手动获取句柄"); } else { label22.Text = GamehWnd.ToString(); label62.Text = GamehWnd.ToString(); logbox1.Items.Insert("手动设置句柄成功 句柄为:"); } }
private void FindPOI() { IntPtr ParenthWnd = new IntPtr(0); IntPtr childHwnd = new IntPtr(0); ParenthWnd = FindWindow(null, "poi"); //判断这个窗体是否有效 if (ParenthWnd != IntPtr.Zero) { POIhWnd = ParenthWnd; childHwnd = FindWindowEx(ParenthWnd, IntPtr.Zero, "Chrome_RenderWidgetHostHWND", null); ActionHandle getsize = new ActionHandle(); Gamewidth = getsize.Getwidth_height(childHwnd)[0]; Gameheight = getsize.Getwidth_height(childHwnd)[1]; if (Gamewidth == 0 || Gameheight == 0) { childHwnd = FindWindowEx(ParenthWnd, childHwnd, "Chrome_RenderWidgetHostHWND", null); } ParentGamehWnd = POIhWnd; GamehWnd = childHwnd; label22.Text = GamehWnd.ToString(); label62.Text = GamehWnd.ToString(); logbox1.Items.Insert("自动动设置句柄成功 句柄为:" + GamehWnd.ToString()); MessageBox.Show("已自动找到POI窗口"); } else { MessageBox.Show("未找到POI窗口请检查"); logbox1.Items.Insert("未找到POI窗口请检查"); } }