public void HiedAllFrom(List <int> notHiedIntPrt) { int topIntprt = mydm.GetSpecialWindow(0); string strInfor = mydm.EnumWindow(topIntprt, "", "", 4); int i = 0; HideFormList.Clear(); foreach (string s in strInfor.Split(',')) { int inPrt = 0; if (int.TryParse(s, out inPrt)) { if (mydm.GetWindowState(inPrt, 0) == 1) //窗口存在 { if (mydm.GetWindowState(inPrt, 2) == 1) //窗口是否可见 { if (mydm.GetWindowState(inPrt, 3) == 0) //窗口是最小化 { if (notHiedIntPrt.Contains(inPrt)) { continue; } i++; string strFromTitle = string.Format("{0}、{1}", i, mydm.GetWindowTitle(inPrt)); HideFormList.Add(strFromTitle, inPrt); mydm.SetWindowState(inPrt, 2); } } } } } }
private void btnGetAllForm_Click(object sender, EventArgs e) { try { int iModer = 4; HideFormList.Clear(); this.listBox1.Items.Clear(); int topIntprt = mydm.GetSpecialWindow(0); string strInfor = mydm.EnumWindow(topIntprt, "", "", iModer); int i = 0; foreach (string s in strInfor.Split(',')) { int inPrt = 0; if (int.TryParse(s, out inPrt)) { if (mydm.GetWindowState(inPrt, 0) == 1) //窗口存在 { if (mydm.GetWindowState(inPrt, 2) == 1) //窗口是否可见 { if (mydm.GetWindowState(inPrt, 3) == 0) //窗口是最小化 { string strFromTitle = mydm.GetWindowTitle(inPrt); if (inPrt == this.Handle.ToInt32()) { continue; } if (!string.IsNullOrWhiteSpace(strFromTitle)) { i++; strFromTitle = string.Format("{0}、{1}", i, strFromTitle); HideFormList.Add(strFromTitle, inPrt); } } } } } } foreach (string key in HideFormList.Keys) { this.listBox1.Items.Add(key); } this.Text = string.Format("共获取到{0}个窗体", this.listBox1.Items.Count); } catch (Exception ex) { MessageBox.Show(ex.Message, "异常"); } }
/// <summary> /// 根据类名与题名查找窗体 /// </summary> /// <param name="title"></param> /// <param name="className"></param> /// <returns></returns> public static List <int> ClassNameAndTitleToParentHwnd(string title, string className) { List <int> FormHwndList = new List <int>(); string strFormHwnds = mydm.EnumWindow(0, title, className, 1 + 2 + 16); foreach (string s in strFormHwnds.Split(',')) { if (!string.IsNullOrEmpty(s)) { FormHwndList.Add(int.Parse(s)); } } return(FormHwndList); }
// 绑定模拟器 public void BindEmu() { int top_Hwnd = dm.FindWindow("", game); GameMsg("顶层句柄为:" + top_Hwnd.ToString()); string child_Hwnd = dm.EnumWindow(top_Hwnd, "", "", 4); GameMsg("子句柄为:" + child_Hwnd); int dm_ret = dm.BindWindowEx(int.Parse(child_Hwnd), "dx.graphic.opengl", "windows", "windows", "", 0); if (dm_ret == 1) { GameMsg("绑定成功"); } else { GameMsg("绑定失败" + "错误代码:" + dm_ret.ToString()); } }
public string EnumWindow(int parent, string title, string class_name, int filter) { return(dm.EnumWindow(parent, title, class_name, filter)); }