示例#1
0
        protected override void Execute(CodeActivityContext context)
        {
            Int32 _delayAfter  = Common.GetValueOrDefault(context, this.DelayAfter, 300);
            Int32 _delayBefore = Common.GetValueOrDefault(context, this.DelayBefore, 300);

            try
            {
                Thread.Sleep(_delayBefore);
                SecureString secureText = SecureText.Get(context);
                IntPtr       inP        = Marshal.SecureStringToBSTR(secureText);//inP为secureStr的句柄
                string       text       = Marshal.PtrToStringBSTR(inP);
                var          selStr     = Selector.Get(context);
                UiElement    element    = Common.GetValueOrDefault(context, this.Element, null);
                if (element == null && selStr != null)
                {
                    element = UiElement.FromSelector(selStr);
                }

                //Int32 pointX = 0;
                //Int32 pointY = 0;
                //if (usePoint)
                //{
                //    pointX = offsetX.Get(context);
                //    pointY = offsetY.Get(context);
                //}
                //else
                //{
                //    if (element != null)
                //    {
                //        pointX = element.GetClickablePoint().X;
                //        pointY = element.GetClickablePoint().Y;
                //        element.SetForeground();
                //    }
                //    else
                //    {
                //        UIAutomationCommon.HandleContinueOnError(context, ContinueOnError, "查找不到元素");
                //        return;
                //    }
                //}
                var point = UIAutomationCommon.GetPoint(context, usePoint, offsetX, offsetY, element);
                if (point.X == -1 && point.Y == -1)
                {
                    UIAutomationCommon.HandleContinueOnError(context, ContinueOnError, Localize.LocalizedResources.GetString("msgNoElementFound"));
                    return;
                }
                /*执行鼠标点击事件*/
                if (isRunClick)
                {
                    UiElement.MouseMoveTo(point);
                    UiElement.MouseAction((Plugins.Shared.Library.UiAutomation.ClickType)ClickType, (Plugins.Shared.Library.UiAutomation.MouseButton)MouseButton);
                }
                else if (true)
                {
                }
                else
                {
                    UIAutomationCommon.HandleContinueOnError(context, ContinueOnError, "找不到键值");
                }
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "发送安全文本执行过程出错", e.Message);
            }
        }
        protected override void Execute(CodeActivityContext context)
        {
            Int32 _delayAfter  = Common.GetValueOrDefault(context, this.DelayAfter, 300);
            Int32 _delayBefore = Common.GetValueOrDefault(context, this.DelayBefore, 300);

            try
            {
                Thread.Sleep(_delayBefore);
                SecureString secureText = SecureText.Get(context);
                IntPtr       inP        = Marshal.SecureStringToBSTR(secureText);//inP为secureStr的句柄
                string       text       = Marshal.PtrToStringBSTR(inP);
                var          selStr     = Selector.Get(context);
                UiElement    element    = Common.GetValueOrDefault(context, this.Element, null);
                if (element == null && selStr != null)
                {
                    element = UiElement.FromSelector(selStr);
                }

                Int32 pointX = 0;
                Int32 pointY = 0;
                if (usePoint)
                {
                    pointX = offsetX.Get(context);
                    pointY = offsetY.Get(context);
                }
                else
                {
                    if (element != null)
                    {
                        pointX = element.GetClickablePoint().X;
                        pointY = element.GetClickablePoint().Y;
                        element.SetForeground();
                    }
                    else
                    {
                        SharedObject.Instance.Output(SharedObject.enOutputType.Error, "有一个错误产生", "查找不到元素");
                        if (ContinueOnError.Get(context))
                        {
                            return;
                        }
                        else
                        {
                            throw new NotImplementedException("查找不到元素");
                        }
                    }
                }
                /*执行鼠标点击事件*/
                if (isRunClick)
                {
                    UiElement.MouseMoveTo(pointX, pointY);
                    UiElement.MouseAction((Plugins.Shared.Library.UiAutomation.ClickType)ClickType, (Plugins.Shared.Library.UiAutomation.MouseButton)MouseButton);
                }
                else if (true)
                {
                }
                else
                {
                    SharedObject.Instance.Output(SharedObject.enOutputType.Error, "有一个错误产生", "找不到键值");
                    if (ContinueOnError.Get(context))
                    {
                        return;
                    }
                    else
                    {
                        throw new NotImplementedException("找不到键值");
                    }
                }
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "发送安全文本执行过程出错", e.Message);
            }
        }