Exemplo n.º 1
0
        void BotMotion(
            FromProcessMeasurement <IMemoryMeasurement> memoryMeasurement,
            IEnumerable <Bot.MotionRecommendation> sequenceMotion)
        {
            var processId = memoryMeasurement?.ProcessId;

            if (!processId.HasValue || null == sequenceMotion || sequenceMotion.IsNullOrEmpty())
            {
                return;
            }
            var process = System.Diagnostics.Process.GetProcessById(processId.Value);

            var listMotionResult = new List <Bot.MotionResult>();
            var startTime        = GetTimeStopwatch();

            botLock.WhenLockIsAvailableEnter(300, () =>
            {
                var motor = new WindowMotor(process.MainWindowHandle);

                foreach (var motion in sequenceMotion)
                {
                    var motionResult =
                        motor.ActSequenceMotion(motion.MotionParam.AsSequenceMotion(memoryMeasurement?.Value));

                    listMotionResult.Add(new Bot.MotionResult
                    {
                        Id      = motion.Id,
                        Success = motionResult?.Success ?? false,
                    });
                }
            }, "MotionExecution");
            BotStepLastMotionResult = new PropertyGenTimespanInt64 <Bot.MotionResult[]>(listMotionResult.ToArray(), startTime, GetTimeStopwatch());

            Thread.Sleep(sequenceMotion.Max(sm => sm.DelayAfterMs ?? FromMotionToMeasurementDelayMilli));
        }
Exemplo n.º 2
0
        public void BookmarkByOverview(string BookmarkName)
        {
            IMemoryMeasurement measurement;
            WindowMotor        motor = new WindowMotor(EveMainWindow.Value);

            Sanderling.Motor.WindowMotor.EnsureWindowIsForeground(EveMainWindow.Value);
            var response = sensor?.MeasurementTakeNewRequest(EveClientId.Value);

            do
            {
                response = sensor?.MeasurementTakeNewRequest(EveClientId.Value);
            } while (null == response);

            measurement = response?.MemoryMeasurement?.Value;
            var overview = measurement.WindowOverview.FirstOrDefault();

            var entry       = overview.ListView.Entry.FirstOrDefault();
            var motionParam = entry.MouseClick(MouseButtonIdEnum.Right);

            motor.ActSequenceMotion(motionParam.AsSequenceMotion(measurement));


            do
            {
                response = sensor?.MeasurementTakeNewRequest(EveClientId.Value);
            } while (null == response);
            measurement = response?.MemoryMeasurement?.Value;
            Sanderling.Interface.MemoryStruct.IMenu menu = measurement.Menu.FirstOrDefault();
            BookmarkByMenu(measurement, menu, "Save Location", BookmarkName);
        }
Exemplo n.º 3
0
        void BotMotion(
            FromProcessMeasurement <IMemoryMeasurement> memoryMeasurement,
            IEnumerable <Bot.MotionRecommendation> sequenceMotion)
        {
            var processId = memoryMeasurement?.ProcessId;

            if (!processId.HasValue || null == sequenceMotion)
            {
                return;
            }

            var process = System.Diagnostics.Process.GetProcessById(processId.Value);

            if (null == process)
            {
                return;
            }

            var startTime = GetTimeStopwatch();

            BotEngine.WinApi.User32.SetForegroundWindow(process.MainWindowHandle);

            var PreviousForegroundWindowHandle = BotEngine.WinApi.User32.GetForegroundWindow();

            if (PreviousForegroundWindowHandle != process.MainWindowHandle)
            {
                Thread.Sleep(100);
                PreviousForegroundWindowHandle = BotEngine.WinApi.User32.GetForegroundWindow();
                if (PreviousForegroundWindowHandle != process.MainWindowHandle)
                {
                    return;
                }
            }

            var motor = new WindowMotor(process.MainWindowHandle);

            var listMotionResult = new List <Bot.MotionResult>();

            foreach (var motion in sequenceMotion.EmptyIfNull())
            {
                var motionResult = motor.ActSequenceMotion(motion.MotionParam.AsSequenceMotion(memoryMeasurement?.Value));

                listMotionResult.Add(new Bot.MotionResult
                {
                    Id      = motion.Id,
                    Success = motionResult?.Success ?? false,
                });
            }

            BotStepLastMotionResult = new PropertyGenTimespanInt64 <Bot.MotionResult[]>(listMotionResult.ToArray(), startTime, GetTimeStopwatch());
        }
        private void BotMotion(
            FromProcessMeasurement <IMemoryMeasurement> memoryMeasurement,
            IEnumerable <MotionRecommendation> sequenceMotion)
        {
            var processId = memoryMeasurement?.ProcessId;

            if (!processId.HasValue || null == sequenceMotion)
            {
                return;
            }

            var process = Process.GetProcessById(processId.Value);

            if (null == process)
            {
                return;
            }

            var startTime = GetTimeStopwatch();

            var motor = new WindowMotor(process.MainWindowHandle);

            var listMotionResult = new List <MotionResult>();

            foreach (var motion in sequenceMotion.EmptyIfNull())
            {
                var motionResult =
                    motor.ActSequenceMotion(motion.MotionParam.AsSequenceMotion(memoryMeasurement?.Value));

                listMotionResult.Add(new MotionResult
                {
                    Id      = motion.Id,
                    Success = motionResult?.Success ?? false
                });
            }

            BotStepLastMotionResult =
                new PropertyGenTimespanInt64 <MotionResult[]>(listMotionResult.ToArray(), startTime, GetTimeStopwatch());

            Thread.Sleep(FromMotionToMeasurementDelayMilli);
        }
Exemplo n.º 5
0
        private void BookmarkByMenu(IMemoryMeasurement measure, IMenu menu, string WhichOne, string BookName)
        {
            WindowMotor        motor = new WindowMotor(EveMainWindow.Value);
            IMemoryMeasurement measureme;
            MotionParam        motionParam;
            var response = sensor?.MeasurementTakeNewRequest(EveClientId.Value);

            WindowsInput.InputSimulator sim = new InputSimulator();
            sim.Keyboard.KeyDown(VirtualKeyCode.MENU).Sleep(200).KeyPress(VirtualKeyCode.VK_D).Sleep(200).KeyUp(VirtualKeyCode.MENU);
            if (null == menu)
            {
                do
                {
                    response = sensor?.MeasurementTakeNewRequest(EveClientId.Value);
                } while (null == response.MemoryMeasurement.Value.Menu);

                menu = response.MemoryMeasurement.Value.Menu.First();
            }


            var menuEntry = menu.Entry.FirstOrDefault(x => Regex.IsMatch(x.Text, WhichOne));

            motionParam = menuEntry.MouseClick(MouseButtonIdEnum.Left);
            motor.ActSequenceMotion(motionParam.AsSequenceMotion(measure));


            do
            {
                response = sensor?.MeasurementTakeNewRequest(EveClientId.Value);
            } while (null == response.MemoryMeasurement.Value.WindowOther.First(p => Regex.IsMatch(p.Caption, "Location")));

            IWindow other =
                response.MemoryMeasurement.Value.WindowOther.First(p => Regex.IsMatch(p.Caption, "Location"));

            //var inputText = other.InputText.First(p => Regex.IsMatch(p.Text, "Wormhole"));
            //WindowsInput.InputSimulator sim = new InputSimulator();
            sim.Keyboard.TextEntry(BookName).Sleep(200).KeyPress(VirtualKeyCode.RETURN);

            sim.Keyboard.Sleep(1000).KeyDown(VirtualKeyCode.MENU).Sleep(200).KeyPress(VirtualKeyCode.VK_D).Sleep(200).KeyUp(VirtualKeyCode.MENU);
        }