Exemplo n.º 1
0
        protected override void StartLoop(NativeActivityContext context)
        {
            var selectorstring = Selector.Get(context);

            selectorstring = OpenRPA.Interfaces.Selector.Selector.ReplaceVariables(selectorstring, context.DataContext);
            var selector     = new Interfaces.Selector.Selector(selectorstring);
            var checkrunning = CheckRunning.Get(context);

            checkrunning = true;
            var pluginname = selector.First().Selector;
            var Plugin     = Plugins.recordPlugins.Where(x => x.Name == pluginname).First();
            var timeout    = Timeout.Get(context);
            var element    = Plugin.LaunchBySelector(selector, checkrunning, timeout);

            Result.Set(context, element);
            _element.Set(context, element);
            if (element != null && element is UIElement ui && Body == null)
            {
                //var window = ((UIElement)element).GetWindow();
                var x           = X.Get(context);
                var y           = Y.Get(context);
                var width       = Width.Get(context);
                var height      = Height.Get(context);
                var animatemove = AnimateMove.Get(context);
                if ((width == 0 && height == 0) || (x == 0 && y == 0))
                {
                }
                else
                {
                    if (animatemove)
                    {
                        ui.MoveWindowTo(x, y, width, height);
                    }
                    if (!animatemove)
                    {
                        ui.SetWindowSize(width, height);
                        ui.SetWindowPosition(x, y);
                    }
                }
            }
            if (element != null && Body != null)
            {
                IncIndex(context);
                SetTotal(context, 1);
                context.ScheduleAction(Body, element, OnBodyComplete);
            }
        }
Exemplo n.º 2
0
        protected override void StartLoop(NativeActivityContext context)
        {
            var selectorstring = Selector.Get(context);

            selectorstring = OpenRPA.Interfaces.Selector.Selector.ReplaceVariables(selectorstring, context.DataContext);
            var selector     = new Interfaces.Selector.Selector(selectorstring);
            var checkrunning = CheckRunning.Get(context);

            checkrunning = true;
            var pluginname = selector.First().Selector;
            var Plugin     = Plugins.recordPlugins.Where(x => x.Name == pluginname).First();
            var timeout    = Timeout.Get(context);

            if (Timeout == null || Timeout.Expression == null)
            {
                timeout = TimeSpan.FromSeconds(3);
            }
            var element = Plugin.LaunchBySelector(selector, checkrunning, timeout);

            Result.Set(context, element);
            _element.Set(context, element);
            if (element != null && element is UIElement ui && Body == null)
            {
                //var window = ((UIElement)element).GetWindow();
                var screen      = Screen.Get(context);
                var x           = X.Get(context);
                var y           = Y.Get(context);
                var width       = Width.Get(context);
                var height      = Height.Get(context);
                var animatemove = AnimateMove.Get(context);
                // if ((width == 0 && height == 0) || (x == 0 && y == 0))
                if (width <= 30 || height <= 10)
                {
                }
                else
                {
                    var allScreens = System.Windows.Forms.Screen.AllScreens.ToList();
                    if (screen < 0)
                    {
                        Log.Warning("screen cannot be below 0, using screen 0");
                        screen = 0;
                    }
                    if (screen >= allScreens.Count)
                    {
                        Log.Warning("screen " + screen + " does not exists, using " + (allScreens.Count - 1) + " instead");
                        screen = allScreens.Count - 1;
                    }
                    x += allScreens[screen].WorkingArea.X;
                    y += allScreens[screen].WorkingArea.Y;
                    if (animatemove)
                    {
                        ui.MoveWindowTo(x, y, width, height);
                    }
                    if (!animatemove)
                    {
                        ui.SetWindowSize(width, height);
                        ui.SetWindowPosition(x, y);
                    }
                }
            }
            if (element != null && Body != null)
            {
                IncIndex(context);
                SetTotal(context, 1);
                context.ScheduleAction(Body, element, OnBodyComplete);
            }
        }