コード例 #1
0
        private void OnHotkeyPressed(object o, HotkeyPressedEvent e)
        {
            var handle = handleService.GetHandle("Diablo III64");

            if (e.PressedHotkey.KeyCode == Keys.Escape && e.PressedHotkey.Modifiers == Keys.None && tokenSource == null)
            {
                InputHelper.SendKey(WindowHelper.GetForegroundWindow(), Keys.Escape);
            }

            if (handle.IsDefault())
            {
                return;
            }

            var actionName = settingsService.GetActionName(e.PressedHotkey);

            if (actionName == ActionName.Pause || (e.PressedHotkey.KeyCode == Keys.Escape && e.PressedHotkey.Modifiers == Keys.None))
            {
                if (tokenSource != null)
                {
                    tokenSource.Cancel();
                    logService.AddEntry(this, $"Cancelling current action... [{actionName}][{e.PressedHotkey}]");
                }
            }
            else if (actionName.IsCancelable())
            {
                if (tokenSource == null)
                {
                    tokenSource = new CancellationTokenSource();
                    var macro = actionFinderService.FindAction(actionName, handle.Handle, tokenSource);

                    ExecuteAndResetTokenSourceAsync(macro);
                    logService.AddEntry(this, $"Beginning to execute... [{actionName}][{e.PressedHotkey}]");
                }
                else
                {
                    tokenSource.Cancel();
                    logService.AddEntry(this, $"Cancelling current action... [{actionName}][{e.PressedHotkey}]");
                }
            }
            else if (!actionName.IsSuspensionAction())
            {
                var macro = actionFinderService.FindAction(actionName, handle.Handle);

                Execute.AndForgetAsync(macro);
                logService.AddEntry(this, $"Beginning to execute... [{actionName}][{e.PressedHotkey}]");
            }
        }
コード例 #2
0
        public Point TransformCoordinate(Point sourceCoordinate, RelativeCoordinatePosition coordinatePosition = RelativeCoordinatePosition.Left, int originalWidth = 1920, int originalHeight = 1080)
        {
            var rect = handleService.GetHandle("Diablo III64").ClientRectangle;

            var originalWidthF  = (float)originalWidth;
            var originalHeightF = (float)originalHeight;

            var scaledY = (int)(rect.Height / originalHeightF * sourceCoordinate.Y);

            int scaledX;

            if (coordinatePosition == RelativeCoordinatePosition.Left)
            {
                scaledX = (int)(rect.Height / originalHeightF * sourceCoordinate.X);
            }
            else if (coordinatePosition == RelativeCoordinatePosition.Right)
            {
                scaledX = (int)(rect.Width - (originalWidthF - sourceCoordinate.X) * rect.Height / originalHeightF);
            }
            else
            {
                scaledX = (int)(sourceCoordinate.X * rect.Height / originalHeightF + (rect.Width - originalWidthF * rect.Height / originalHeightF) / 2.0);
            }

            return(new Point {
                X = scaledX, Y = scaledY
            });
        }
コード例 #3
0
        public Bitmap CaptureWindow(string processName)
        {
            var handle = handleService.GetHandle(processName);

            if (windowBitmaps.ContainsKey(processName) && !handle.IsDefault())
            {
                return(CaptureWindow(handle.Handle, windowBitmaps[processName], graphics[processName]));
            }

            return(CaptureWindow(handle.Handle));
        }
コード例 #4
0
        public OverviewTabViewModel(IEventBus eventBus, IModelService modelService, IHandleService handleService, ISettingsService settingsService, IStartProcessService processService)
        {
            this.eventBus        = eventBus;
            this.modelService    = modelService;
            this.handleService   = handleService;
            this.settingsService = settingsService;
            this.processService  = processService;

            var playerInformationChanged = new Subscription <PlayerInformationChangedEvent>(OnPlayerInformationChanged);
            var skillRecognitionChanged  = new Subscription <SkillRecognitionChangedEvent>(OnSkillRecognitionChanged);
            var worldInformationChanged  = new Subscription <WorldInformationChangedEvent>(OnWorldInformationChanged);
            var skillCanBeCasted         = new Subscription <SkillCanBeCastedEvent>(OnSkillCanBeCasted);
            var hotkeyPressed            = new Subscription <HotkeyPressedEvent>(OnHotkeyPressed);

            SubscribeBus(playerInformationChanged);
            SubscribeBus(skillRecognitionChanged);
            SubscribeBus(worldInformationChanged);
            SubscribeBus(skillCanBeCasted);
            SubscribeBus(hotkeyPressed);

            handleService.HandleStatusChanged += OnHandleChanged;

            CurrentSkills = new ObservableCollection <string>
            {
                "pack://application:,,,/Resource/Skill/EmptyFrame.png",
                "pack://application:,,,/Resource/Skill/EmptyFrame.png",
                "pack://application:,,,/Resource/Skill/EmptyFrame.png",
                "pack://application:,,,/Resource/Skill/EmptyFrame.png",
                "pack://application:,,,/Resource/Skill/EmptyFrame.png",
                "pack://application:,,,/Resource/Skill/EmptyFrame.png",
            };

            CurrentSkillState = new ObservableCollection <string> {
                "Cant cast", "Cant cast", "Cant cast", "Cant cast", "Cant cast", "Cant cast"
            };
            CurrentActiveState = new ObservableCollection <string> {
                "Not active", "Not active", "Not active", "Not active", "Not active", "Not active",
            };
            CurrentPlayerClass     = "pack://application:,,,/Resource/Skill/EmptyFrame.png";
            CurrentHealth          = 0;
            CurrentPrimaryResource = 0;
            CurrentPrimaryResource = 0;

            var handle = handleService.GetHandle("Diablo III64");

            DiabloProcessId       = handle != null ? handle.ProcessId : 0;
            DiabloClientRectangle = handle != null ? $"{handle.ClientRectangle.Width}x{handle.ClientRectangle.Height}" : "0x0";

            SkillIndexSuspensionStatus = new ObservableCollection <bool>(settingsService.SmartFeatureSettings.SkillSuspensionStatus);
        }
コード例 #5
0
        private void OnSkilCanBeCasted(object o, SkillCanBeCastedEvent @event)
        {
            if (!settingsService.SmartFeatureSettings.SkillCastingEnabled)
            {
                return;
            }

            var handle = handleService.GetHandle("Diablo III64");

            if (handle.IsDefault() ||
                !settingsService.SkillIsEnabled(@event.SkillName) ||
                settingsService.SkillIndexIsSuspended(@event.SkillIndex))
            {
                return;
            }

            Action action;

            if (@event.SkillIndex <= 3)
            {
                var key = settingsService.Settings.SkillKeybindings[@event.SkillIndex];
                action = () => InputHelper.SendKey(handle.Handle, key);
            }
            else if (@event.SkillIndex == 4)
            {
                action = () => InputHelper.SendClickAtCursorPos(handle.Handle, MouseButtons.Left);
            }
            else
            {
                action = () => InputHelper.SendClickAtCursorPos(handle.Handle, MouseButtons.Right);
            }

            var condition = conditionFinderService.FindCondition(@event.SkillName);

            if (condition.Invoke(modelService.Player,
                                 modelService.World,
                                 modelService.GetSkill(@event.SkillIndex)))
            {
                Execute.AndForgetAsync(action);
                logService.AddEntry(this, $"Clicking skill... [{@event.SkillName}][{@event.SkillIndex}]", LogLevel.Debug);
            }
            else
            {
                logService.AddEntry(this, $"Condition for skill not fulfilled... [{@event.SkillName}][{@event.SkillIndex}]", LogLevel.Debug);
            }
        }