protected override void DoWork() { FireRequestMainStream(); AutoClickHandlers.SendKeyUp(_hWnd, Keys.ShiftKey); // Close all open tabs AutoClickHandlers.SendKeyPress(_hWnd, Keys.Space, 300); AutoClickHandlers.SendKeyPress(_hWnd, Keys.Space, 100); // Open inventory AutoClickHandlers.SendKeyPress(_hWnd, Keys.V, 300); AutoClickHandlers.SendKeyDown(_hWnd, Keys.ShiftKey); // HP AutoClickHandlers.SendMouseToPoint(_hWnd, PotPosition.HP, 200); AutoClickHandlers.SendKeyPress(_hWnd, KeyHP, 200); // MP AutoClickHandlers.SendMouseToPoint(_hWnd, PotPosition.MP, 200); AutoClickHandlers.SendKeyPress(_hWnd, KeyMP, 200); // STM AutoClickHandlers.SendMouseToPoint(_hWnd, PotPosition.STM, 200); AutoClickHandlers.SendKeyPress(_hWnd, KeySTM, 200); AutoClickHandlers.SendKeyUp(_hWnd, Keys.ShiftKey); // Close inventory AutoClickHandlers.SendKeyPress(_hWnd, Keys.Space, 300); AutoClickHandlers.SendKeyPress(_hWnd, Keys.Space, 100); FireReleaseMainStream(); }
private bool ProcessMeleeAttack(BlobCountingObjectsProcessing motionProcessing, Point center) { List <double> distances = new List <double>(); double minDistance = 0; Point targetPoint = center; RECT minDistanceRectangle = new RECT(); motionProcessing.ObjectRectangles.ToList().ForEach(x => { RECT rect = x; double temp = (rect.Center.X - center.X) ^ 2 + (rect.Center.Y - center.Y) ^ 2; double distance = Math.Sqrt(temp); distances.Add(distance); if (distance <= distances.Min() && distance > .75) { minDistance = distance; targetPoint = rect.Center; minDistanceRectangle = rect; } }); if (targetPoint.X == center.X && targetPoint.Y == center.Y || !VerifyTarget(minDistanceRectangle)) { return(false); } AutoClickHandlers.SendKeyDown(_hWnd, Keys.ShiftKey); AutoClickHandlers.LeftClickOnPoint(_hWnd, targetPoint.ScaleDownToClientPoint(_hWnd)); AutoClickHandlers.SendKeyUp(_hWnd, Keys.ShiftKey, 50); return(true); }
private bool ProcessRangeAttack(RECT rect) { if (!VerifyTarget(rect)) { return(false); } AutoClickHandlers.SendKeyDown(_hWnd, Keys.ShiftKey); AutoClickHandlers.LeftClickOnPoint(_hWnd, rect.Center.ScaleDownToClientPoint(_hWnd)); AutoClickHandlers.SendKeyUp(_hWnd, Keys.ShiftKey, 50); return(true); }
private void RequestMainStreamAndUsePot(decimal currentValue, int valueToUsePot, Keys key) { if (currentValue < valueToUsePot) { FireRequestMainStream(); AutoClickHandlers.SendKeyUp(_hWnd, Keys.ShiftKey); AutoClickHandlers.SendKeyPress(_hWnd, key, 50); FireReleaseMainStream(); } }
protected override void DoWork() { FireRequestMainStream(); Thread.Sleep(100); if (!_mainStream) { return; } BlobCountingObjectsProcessing motionProcessing = new BlobCountingObjectsProcessing(5, 2); MotionDetector detector = new MotionDetector(new TwoFramesDifferenceDetector(), motionProcessing); int i = 0; while (i < 5 && _mainStream) { using (Bitmap backgroundFrame = (Bitmap)ScreenCapture.CaptureWindow(_hWnd)) { detector.MotionZones = new Rectangle[] { ImageProcessing.GetRectangleAreaFromCenter(backgroundFrame, 35) }; detector.ProcessFrame(backgroundFrame.FilterForBlackTags()); AutoClickHandlers.SendKeyDown(_hWnd, Keys.A); Thread.Sleep(200); using (Bitmap currentFrame = (Bitmap)ScreenCapture.CaptureWindow(_hWnd)) { if (detector.ProcessFrame(currentFrame.FilterForBlackTags()) > 0.0002 && motionProcessing.ObjectsCount >= 1) { RECT rect = motionProcessing.ObjectRectangles.FirstOrDefault(); AutoClickHandlers.LeftClickOnPoint(_hWnd, rect.Center.ScaleDownToClientPoint(_hWnd)); Thread.Sleep(250); } else { AutoClickHandlers.SendKeyUp(_hWnd, Keys.A); FireReleaseMainStream(); break; } } AutoClickHandlers.SendKeyUp(_hWnd, Keys.A); Thread.Sleep(200); } i++; } FireReleaseMainStream(); }
private void BtnPotPositionCapture_Click(object sender, EventArgs e) { MainForm form = Parent.Parent.Parent.Parent as MainForm; form.StatusLabel.Text = Env.ProgramName; // Close all open tabs AutoClickHandlers.SendKeyPress(HWnd, Keys.Space, 300); // Open inventory AutoClickHandlers.SendKeyPress(HWnd, Keys.V, 300); SnippingTool.AreaSelected += OnAreaSelected; SnippingTool.Snip(HWnd); }
protected override void DoWork() { foreach (BuffItem buff in Buffs) { FireRequestMainStream(); Thread.Sleep(100); if (!_mainStream) { return; } if (buff.DecrementTrueIfCounter0()) { DateTime timeToStop = DateTime.Now.AddSeconds(1); AutoClickHandlers.SendKeyUp(_hWnd, Keys.ShiftKey); do { // Set skill hotkey. AutoClickHandlers.SendKeyPress(_hWnd, buff.Key); AutoClickHandlers.SendMouseToPoint(_hWnd, Master.Instance.ScreenResolution.Center); // Prevent stuck key. AutoClickHandlers.SendKeyUp(_hWnd, Keys.ShiftKey); // Use skills. AutoClickHandlers.RightClick(_hWnd, 500); if (!_mainStream) { break; } } while (timeToStop > DateTime.Now); if (!_mainStream) { buff.Counter = 0; } } FireReleaseMainStream(); } }
private bool VerifyTarget(RECT minDistanceRectangle) { BlobCountingObjectsProcessing tagFilterProcessing = new BlobCountingObjectsProcessing(5, 2); MotionDetector tagDetector = new MotionDetector(new TwoFramesDifferenceDetector(), tagFilterProcessing) { MotionZones = new Rectangle[] { new RECT(minDistanceRectangle.Left, 0, minDistanceRectangle.Right, minDistanceRectangle.Bottom) } }; using (Bitmap backgroundFrame = (Bitmap)ScreenCapture.CaptureWindow(_hWnd)) { tagDetector.ProcessFrame(backgroundFrame.FilterForBlackTags()); AutoClickHandlers.SendMouseToPoint(_hWnd, minDistanceRectangle.Center.ScaleDownToClientPoint(_hWnd)); Thread.Sleep(500); using (Bitmap currentFrame = (Bitmap)ScreenCapture.CaptureWindow(_hWnd)) { if (tagDetector.ProcessFrame(currentFrame.FilterForBlackTags()) > 0.0002 && tagFilterProcessing.ObjectsCount >= 1) { return(true); } } } return(false); }
protected override void DoWork() { AutoClickHandlers.SendKeyUp(_hWnd, Keys.A); Stop(); }
protected override void DoWork() { if (!_mainStream) { return; } BlobCountingObjectsProcessing motionProcessing = new BlobCountingObjectsProcessing(20, 50); MotionDetector detector = new MotionDetector(new TwoFramesDifferenceDetector(), motionProcessing); using (Bitmap screenCapture = (Bitmap)ScreenCapture.CaptureWindow(_hWnd)) { detector.MotionZones = new Rectangle[] { ImageProcessing.GetRectangleAreaFromCenter(screenCapture, 75) }; } bool found = false; AutoClickHandlers.SendKeyPress(_hWnd, MainSkillHotkey); int trial = 0; while (!found && _mainStream) { using (Bitmap screenCapture = (Bitmap)ScreenCapture.CaptureWindow(_hWnd)) { if (detector.ProcessFrame(screenCapture.FilterForAutoAttacking()) > 0.002 && motionProcessing.ObjectsCount > 0) { switch (Style) { case AttackStyleType.Melee_Attack: { int i = AutoClickHandlers.Random(0, 5); if (i == 0) { RECT rect = motionProcessing.ObjectRectangles.FirstOrDefault(); found = ProcessSpellWithTarget(rect); break; } Point center = new Point(screenCapture.Width / 2, screenCapture.Height / 2); found = ProcessMeleeAttack(motionProcessing, center); break; } case AttackStyleType.Range_Attack: { RECT rect = motionProcessing.ObjectRectangles.FirstOrDefault(); int i = AutoClickHandlers.Random(0, 5); if (i == 0) { found = ProcessSpellWithTarget(rect); break; } found = ProcessRangeAttack(rect); break; } case AttackStyleType.Spell_With_Target: { RECT rect = motionProcessing.ObjectRectangles.FirstOrDefault(); found = ProcessSpellWithTarget(rect); break; } case AttackStyleType.Spell_AOE: { detector.MotionZones = new Rectangle[] { ImageProcessing.GetRectangleAreaFromCenter(screenCapture, 25) }; if (motionProcessing.ObjectsCount < 5) { break; } AutoClickHandlers.RightClick(_hWnd); found = true; break; } default: break; } } } trial++; if (trial > 10) { break; } } }
protected override void DoWork() { AutoClickHandlers.SendKeyUp(_hWnd, Keys.ShiftKey, 50); AutoClickHandlers.SendKeyUp(_hWnd, Keys.ControlKey, 50); Stop(); }