Beispiel #1
0
        private void OnMouseUp(InputEventArgs e)
        {
            isMouseDown = false;
            var thread = new Thread(new ThreadStart(() =>
            {
                try
                {
                    Log.Debug(string.Format("Windows.Recording::OnMouseUp::begin"));
                    var re = new RecordEvent
                    {
                        Button = e.Button
                    }; var a = new GetElement {
                        DisplayName = e.Element.Name
                    };
                    var sw = new System.Diagnostics.Stopwatch();
                    sw.Start();
                    WindowsSelector sel = null;
                    // sel = new WindowsSelector(e.Element.rawElement, null, true);
                    sel = new WindowsSelector(e.Element.RawElement, null, PluginConfig.enum_selector_properties);
                    if (sel.Count < 2)
                    {
                        return;
                    }
                    if (sel == null)
                    {
                        return;
                    }
                    a.Selector   = sel.ToString();
                    a.MaxResults = 1;
                    a.Image      = e.Element.ImageString();
                    re.OffsetX   = e.X - e.Element.Rectangle.X;
                    re.OffsetY   = e.Y - e.Element.Rectangle.Y;
                    re.UIElement = e.Element;
                    re.Element   = e.Element;
                    re.Selector  = sel;
                    re.X         = e.X;
                    re.Y         = e.Y;
                    if (sel.Count > 3)
                    {
                        var p1 = sel[1].Properties.Where(x => x.Name == "ClassName").FirstOrDefault();
                        var p2 = sel[2].Properties.Where(x => x.Name == "AutomationId").FirstOrDefault();
                        if (p1 != null && p2 != null)
                        {
                            if (p1.Value.StartsWith("Windows.UI") && p2.Value == "SplitViewFrameXAMLWindow")
                            {
                                re.SupportVirtualClick = false;
                            }
                        }
                    }
                    re.a             = new GetElementResult(a);
                    re.SupportInput  = e.Element.SupportInput;
                    re.SupportSelect = e.Element.SupportSelect;
                    Log.Debug(string.Format("Windows.Recording::OnMouseUp::end {0:mm\\:ss\\.fff}", sw.Elapsed));
                    OnUserAction?.Invoke(this, re);
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());
                }
            }));

            thread.IsBackground = true;
            thread.Start();
        }
Beispiel #2
0
        private void _OnMouseMove(InputEventArgs e)
        {
            if (isMouseDown)
            {
                return;
            }
            if (CurrentProcessId == 0)
            {
                CurrentProcessId = System.Diagnostics.Process.GetCurrentProcess().Id;
            }
            var thread = new Thread(new ThreadStart(() =>
            {
                try
                {
                    lock (_lock)
                    {
                        if (_processing)
                        {
                            return;
                        }
                        _processing = true;
                    }
                    try
                    {
                        if (e.Element == null)
                        {
                            var Element = AutomationHelper.GetFromPoint(e.X, e.Y);
                            if (Element != null)
                            {
                                e.SetElement(Element);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex, "");
                    }
                    lock (_lock)
                    {
                        _processing = false;
                    }
                    if (e.Element == null)
                    {
                        return;
                    }

                    if (e.Element.RawElement.Properties.ProcessId.IsSupported && e.Element.RawElement.Properties.ProcessId.ValueOrDefault == CurrentProcessId)
                    {
                        return;
                    }
                    var re = new RecordEvent
                    {
                        Button    = e.Button,
                        OffsetX   = e.X - e.Element.Rectangle.X,
                        OffsetY   = e.Y - e.Element.Rectangle.Y,
                        Element   = e.Element,
                        UIElement = e.Element,
                        X         = e.X,
                        Y         = e.Y
                    }; OnMouseMove?.Invoke(this, re);
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "");
                }
            }));

            thread.IsBackground = true;
            thread.Start();
        }