/// <summary> /// 綁定窗口DM,获取客户端大小,启动提示消除Timer,获取人物职业 /// </summary> /// <param name="className">類名</param> /// <returns>0失敗,1成功</returns> public int BindDM(string className, int pid, int handle) { Log("BindDM:" + className + ",pid:" + pid.ToString() + ",handle:" + handle.ToString()); int ret = 0; IntPtr p = IntPtr.Zero; if (pid == 0 && handle == 0) { p = FindWindow(className, null); if (p == IntPtr.Zero) { Log("BindDM:" + "找不到窗口,类名:" + className); throw new Exception("找不到窗口,类名:" + className); } } else { if (handle != 0) p = new IntPtr(handle); else { p = GetMainWindowHandle(pid); } } hwnd = p.ToInt32(); //dm.SetWindowState(p.ToInt32(), 1);//激活窗口 Thread.Sleep(200); //ret = dm.BindWindow(p.ToInt32(), "normal", "windows", "windows", 0); ret = dm.BindWindow(hwnd, "dx2", "dx", "dx", 0); Log("BindWindow"); if (ret == 0) { throw new Exception("绑定失败"); } //ret = dm.LockInput(1); object w, h; ret = dm.GetClientSize(hwnd, out w, out h); if (ret == 0) { throw new Exception("获取窗口客户区失败"); } clientH = (int)h; clientW = (int)w; Thread.Sleep(200); Log("客户区域,W:" + clientW.ToString() + ";H:" + clientH.ToString()); pro = GetUserProfession(); ProDtInfo = GetProfessionDtInfo(pro); Log("职业:" + pro.ToString()); //CNoticeTimer.Start(); return ret; }
private void FillProDtInfoList() { ProDtInfoList=new List<ProfessionDtInfo>(); foreach (Profession pro in Enum.GetValues(typeof(Profession))) { ProfessionDtInfo p = new ProfessionDtInfo(); p.pro = pro; switch (pro) { case Profession.贤士: { p.dtPath = p地图_京燕山庄; p.xlPath = p自动寻路_京燕山庄_江程; p.xlNpcPath = p京燕山庄_NPC_江程; break; }; case Profession.剑客: { p.dtPath = p地图_空仞山; p.xlPath = p自动寻路_空仞山_冷竹; p.xlNpcPath = p空仞山_NPC_冷竹; break; }; case Profession.药师: { p.dtPath = p地图_朝云珠海; p.xlPath = p自动寻路_朝云珠海_贾济世; p.xlNpcPath = p朝云珠海_NPC_贾济世; break; }; case Profession.火枪手: { p.dtPath = p地图_兵工厂; p.xlPath = p自动寻路_兵工厂_萧隆; p.xlNpcPath = p兵工厂_NPC_萧隆; break; }; case Profession.猛将: { p.dtPath = p地图_龙旗营; p.xlPath = p自动寻路_龙旗营_杨立威; p.xlNpcPath = p龙旗营_NPC_杨立威; break; }; case Profession.隐者: { p.dtPath = p地图_锁魂窟; p.xlPath = p自动寻路_锁魂窟_宋一成; p.xlNpcPath = p锁魂窟_NPC_宋一成; break; }; default: { throw new Exception("未知职业"); } } ProDtInfoList.Add(p); } }