예제 #1
0
        private void OnBodyComplete(NativeActivityContext context, ActivityInstance completedInstance)
        {
            IElement element = _element.Get(context);

            if (element != null && element is UIElement ui)
            {
                //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)
                //{
                //    ui.SetWindowSize(width, height);
                //}
                //if (x>0 && y>0)
                //{
                // if (animatemove) ui.MoveWindowTo(x, y);
                if (animatemove)
                {
                    ui.MoveWindowTo(x, y, width, height);
                }
                if (!animatemove)
                {
                    ui.SetWindowSize(width, height);
                    ui.SetWindowPosition(x, y);
                }
                //}
            }
        }
예제 #2
0
        private void OnBodyComplete(NativeActivityContext context, ActivityInstance completedInstance)
        {
            if (breakRequested)
            {
                return;
            }
            IElement element = _element.Get(context);

            if (element != null && element is UIElement ui)
            {
                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 (animatemove)
                {
                    ui.MoveWindowTo(x, y, width, height);
                }
                if (!animatemove)
                {
                    ui.SetWindowSize(width, height);
                    ui.SetWindowPosition(x, y);
                }
            }
        }
예제 #3
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);
            }
        }
예제 #4
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);
            }
        }
예제 #5
0
        protected override void Execute(CodeActivityContext context)
        {
            var el = Element.Get(context);

            if (el == null)
            {
                throw new ArgumentException("element cannot be null");
            }
            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);
            var windowstate = WindowState.Get(context);

            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;
                var _window = ((UIElement)el).GetWindow();
                var window  = new UIElement(_window);
                if (_window.Properties.NativeWindowHandle.IsSupported)
                {
                    GenericTools.Restore(_window.Properties.NativeWindowHandle.Value);
                }
                if (animatemove)
                {
                    window.MoveWindowTo(x, y, width, height);
                }
                if (!animatemove)
                {
                    window.SetWindowSize(width, height);
                    window.SetWindowPosition(x, y);
                }
                if (!string.IsNullOrEmpty(windowstate) && _window.Properties.NativeWindowHandle.IsSupported)
                {
                    switch (windowstate)
                    {
                    case "Normal": GenericTools.Restore(_window.Properties.NativeWindowHandle.Value); break;

                    case "Minimized": GenericTools.Minimize(_window.Properties.NativeWindowHandle.Value); break;

                    case "Maximized": GenericTools.Maximized(_window.Properties.NativeWindowHandle.Value); break;
                    }
                }
            }
        }