private void GlobalHookKeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == _appSettings.Value.KeyBind)
            {
                AutomationService.StopTimer();
                Unsubscribe();
                e.Handled = true;
                return;
            }

            RegisterKeyPress(e.KeyChar);
            e.Handled = true;
        }
Beispiel #2
0
        private void OnTimerTickForControlChecking(object sender, ElapsedEventArgs e)
        {
            _execTimer += _timerInterval;
            if (CancelHasBeenRequested(OnTimerTickForControlChecking))
            {
                return;
            }

            if (_execTimer > _appSettings.Value.MaxActionDelay)
            {
                StopTimer(OnTimerTickForControlChecking);
                //_parentWindow.Invoke(new Action(() => _parentWindow.DisplayMessage($"Control for cursor action #{_currentlyProcessingAction.CurrentAction.ActionNumber} could not be found", "Error")));
                //_parentWindow.Invoke(new Action(() => _parentWindow.CloseProcessingForm()));
            }

            FlaUI.Core.AutomationElements.AutomationElement hoveredElement = AutomationService.GetHoveredElement();
            try
            {
                if (_currentlyProcessingAction.CurrentAction.ControlType == "" || hoveredElement == null ||
                    hoveredElement.ControlType.ToString() != _currentlyProcessingAction.CurrentAction.ControlType)
                {
                    return;
                }

                if (_appSettings.Value.CheckControlName && hoveredElement.Name != _currentlyProcessingAction.CurrentAction.ControlName)
                {
                    return;
                }

                ElementHighlighterService.HighlightElement(hoveredElement, Color.BlueViolet);
                ExecuteMouseClick(_currentlyProcessingAction.CurrentAction);
            }
            catch (PropertyNotSupportedException)
            {
                //hoveredElement is not supported
            }
        }