public void btnAuto_Click(object sender, RoutedEventArgs e) { if (!DataUtil.Game.isOnline) { return; } if (webHandle == IntPtr.Zero) { webHandle = mainWeb.Handle; webHandle = CordCol.GetWebHandle(webHandle); //独立出的获取句柄 //StringBuilder className = new StringBuilder(100); //while (className.ToString() != "Internet Explorer_Server") // 浏览器组件类获取 //{ // webHandle = GetWindow(webHandle, 5); // 获取子窗口的句柄 // GetClassName(webHandle, className, className.Capacity); //} } if (DataUtil.Game.isAuto) { MiscHelper.SetAutoGo(false); } else if (DataUtil.Game.canAuto) { MiscHelper.SetAutoGo(true); } }
/// <summary> /// 获取当前鼠标坐标与像素并输出到窗口 /// </summary> /// <param name="ActHand">底层Handle(像素)</param> private void GetCord(IntPtr ActHand) { System.Drawing.Point Pointy = GetMousePosition(); GetWindowRect(ActHand, out CordCol.RECT lprect); int a; int b; a = Pointy.X - lprect.Left; b = Pointy.Y - lprect.Top; System.Drawing.Color colorout = CordCol.GetPixelColor(ActHand, Pointy.X - lprect.Left, Pointy.Y - lprect.Top); Dispatcher.Invoke(() => { Int32.TryParse(XBox.Text, out int Xin); Int32.TryParse(YBox.Text, out int Yin); System.Drawing.Color colorin = CordCol.GetPixelColor(ActHand, Xin, Yin); text1.Text = "( " + a + ", " + b + ")"; text2.Text = colorout.R.ToString() + " " + colorout.G.ToString() + " " + colorout.B.ToString(); Output.Text = colorin.R.ToString() + " " + colorin.G.ToString() + " " + colorin.B.ToString(); }); }
/// <summary> /// 启动坐标与颜色窗口 /// </summary> /// <param name="TopHandle">整个助理Handle</param> public CordWindow(IntPtr TopHandle) { InitializeComponent(); IntPtr Handle = CordCol.GetWebHandle(TopHandle); System.Timers.Timer aTimer = new System.Timers.Timer(100); XBox.Text = "0"; YBox.Text = "0"; aTimer.Elapsed += (s, e) => GetCord(Handle); aTimer.Enabled = true; }