Beispiel #1
0
        private void OnMessage(NativeMessagingMessage message)
        {
            try
            {
                if (message.uiy > 0 && message.uix > 0 && message.uiwidth > 0 && message.uiheight > 0)
                {
                    if (!string.IsNullOrEmpty(message.data))
                    {
                        LastElement = new NMElement(message);
                    }
                    else
                    {
                        LastElement = new NMElement(message);
                    }
                }

                if (message.functionName == "click")
                {
                    if (IsRecording)
                    {
                        if (LastElement == null)
                        {
                            return;
                        }
                        var re = new RecordEvent
                        {
                            Button = Input.MouseButton.Left
                        }; var a = new GetElement {
                            DisplayName = LastElement.ToString()
                        };

                        var selector = new NMSelector(LastElement, null, true, null);
                        a.Selector   = selector.ToString();
                        a.Image      = LastElement.ImageString();
                        a.MaxResults = 1;

                        re.Selector      = selector;
                        re.a             = new GetElementResult(a);
                        re.SupportInput  = LastElement.SupportInput;
                        re.SupportSelect = false;
                        re.ClickHandled  = true;
                        OnUserAction?.Invoke(this, re);
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
        }
Beispiel #2
0
        private void OnMessage(NativeMessagingMessage message)
        {
            try
            {
                //lock(_lock)
                //{

                //    //if (dpiscale == 0)
                //    //{
                //    //    dpiscale = NativeMethods.getScalingFactor();
                //    //} else
                //    //{
                //    //    dpiscale = NativeMethods.getScalingFactor();
                //    //}
                //    var dpi = NativeMethods.GetDpiForSystem();
                //    dpiscale = 1;
                //    if (dpi == 96) dpiscale = 1;
                //    if (dpi == 120) dpiscale = 1.25f;
                //    if (dpi == 144) dpiscale = 1.5f;
                //    if (dpi == 192) dpiscale = 2;
                //}
                if (message.uiy > 0 && message.uix > 0 && message.uiwidth > 0 && message.uiheight > 0)
                {
                    //message.uiy = (int)(message.uiy * dpiscale);
                    //message.uix = (int)(message.uix * dpiscale);
                    //message.uiwidth = (int)(message.uiwidth * dpiscale);
                    //message.uiheight = (int)(message.uiheight * dpiscale);
                    if (dpiscale == 1.25)
                    {
                        message.uiy += 158;
                    }
                    LastElement = new NMElement(message);
                }

                if (message.functionName == "click")
                {
                    if (IsRecording)
                    {
                        if (LastElement == null)
                        {
                            return;
                        }
                        var re = new RecordEvent
                        {
                            Button = Input.MouseButton.Left
                        }; var a = new GetElement {
                            DisplayName = LastElement.ToString()
                        };

                        message.tab = NMHook.tabs.Where(x => x.id == message.tabid && x.windowId == message.windowId).FirstOrDefault();

                        var selector = new NMSelector(LastElement, null, true, null);
                        a.Selector   = selector.ToString();
                        a.Image      = LastElement.ImageString();
                        a.MaxResults = 1;

                        re.Selector      = selector;
                        re.a             = new GetElementResult(a);
                        re.SupportInput  = LastElement.SupportInput;
                        re.SupportSelect = false;
                        re.ClickHandled  = true;
                        OnUserAction?.Invoke(this, re);
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
        }