Ejemplo 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));
        }
Ejemplo 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);
        }
Ejemplo 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());
        }
Ejemplo n.º 4
0
        public void MeasurementReceived(BotEngine.Interface.FromProcessMeasurement <IMemoryMeasurement> measurement)
        {
            InputSimulator sim      = new InputSimulator();
            var            overview = measurement?.Value.WindowOverview.FirstOrDefault();
            var            entry    = overview.ListView.Entry.First(x =>
                                                                    Regex.IsMatch(x.LabelText.ElementAt(2).Text, @"Wormhole [A-Z]"));
            string toSearch    = entry.LabelText.ElementAt(2).Text.Split(' ')[1];
            string Hole        = (toSearch.Contains("K162")) ? "UNK" : Worm.GetHole(toSearch);
            var    scanResults = measurement?.Value.WindowProbeScanner.First().ScanResultView.Entry.FirstOrDefault();
            string scanID      = scanResults?.LabelText.ElementAt(1).Text.Substring(0, 3);

            if (Regex.IsMatch(Hole, @"Barbican|Conflux|Redoubt|Sentinel|Vidette"))
            {
                scanID = "Drifter";
            }
            ClipString = string.Format(ClipString, scanID, Hole);
            bool isEol = false;

            if (Hole.Contains("UNK"))
            {
                var motor = new WindowMotor(EveMainWindow.Value);
                ShowInfo(overview.ListView.Entry.First(x => Regex.IsMatch(x.LabelText.ElementAt(2).Text, @"Wormhole [A-Z]")), measurement);
                //ShowInfo(overview.ListView.Entry.FirstOrDefault(x => x.LabelText.ElementAt(2).Text.Contains("Wormhole")),measurement);
                Sanderling.Interface.FromInterfaceResponse response = null;
                do
                {
                    response = sensor?.MeasurementTakeNewRequest(EveClientId.Value);
                } while (null == response);

                var InfoWindow =
                    response.MemoryMeasurement?.Value.WindowOther.First(x => x.Caption.Contains("formation"));
                SelectAndCopy(sim, InfoWindow);

                ClipString = string.Format(ClipString, scanID, Hole);//, Extensions.Julian4());
                bool isEOL = false;

                var results = Classify(ClipString, out isEOL);

                string Name = (string.IsNullOrEmpty(results)) ? ClipString : results;
                Name += ((isEOL) ? " eol" + Extensions.Julian4() : Extensions.Julian4());
                BookmarkByOverview(Name);
                ///// Use this as a way of saying my program is done reset the
                ///// ScanHelper program foreground

                //Thread.Sleep(50);
                //SetForegroundWindow(new System.Windows.Interop.WindowInteropHelper(App.Current.MainWindow).Handle);
                //   App.Current.MainWindow.Close();
            }
            BookmarkByOverview(ClipString + Extensions.Julian4());
        }
        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);
        }
Ejemplo n.º 6
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);
        }