public async override Task RunCommand(object sender)
        {
            var engine        = (IAutomationEngineInstance)sender;
            var browserObject = ((OBAppInstance)await v_InstanceName.EvaluateCode(engine)).Value;
            var chromeProcess = (Process)browserObject;

            User32Functions.CloseWindow(chromeProcess.MainWindowHandle);
        }
예제 #2
0
        public override void RunCommand(object sender)
        {
            var    engine        = (AutomationEngineInstance)sender;
            string windowName    = v_WindowName.ConvertUserVariableToString(engine);
            var    targetWindows = User32Functions.FindTargetWindows(windowName);

            //loop each window
            foreach (var targetedWindow in targetWindows)
            {
                User32Functions.CloseWindow(targetedWindow);
            }
        }
예제 #3
0
        public override void RunCommand(object sender)
        {
            string windowName = v_WindowName.ConvertToUserVariable(sender);


            var targetWindows = User32Functions.FindTargetWindows(windowName);

            //loop each window
            foreach (var targetedWindow in targetWindows)
            {
                User32Functions.CloseWindow(targetedWindow);
            }
        }
예제 #4
0
        public async override Task RunCommand(object sender)
        {
            var    engine     = (IAutomationEngineInstance)sender;
            string windowName = (string)await v_WindowName.EvaluateCode(engine);

            int timeout = (int)await v_Timeout.EvaluateCode(engine);

            DateTime      timeToEnd = DateTime.Now.AddSeconds(timeout);
            List <IntPtr> targetWindows;

            while (timeToEnd >= DateTime.Now)
            {
                try
                {
                    if (engine.IsCancellationPending)
                    {
                        break;
                    }
                    targetWindows = User32Functions.FindTargetWindows(windowName);
                    if (targetWindows.Count == 0)
                    {
                        throw new Exception("Window Not Yet Found... ");
                    }
                    break;
                }
                catch (Exception)
                {
                    engine.ReportProgress($"Window '{windowName}' Not Yet Found... {(timeToEnd - DateTime.Now).Minutes}m, {(timeToEnd - DateTime.Now).Seconds}s remain");
                    Thread.Sleep(500);
                }
            }

            targetWindows = User32Functions.FindTargetWindows(windowName);

            //loop each window
            foreach (var targetedWindow in targetWindows)
            {
                User32Functions.CloseWindow(targetedWindow);
            }
        }
예제 #5
0
        public override void RunCommand(object sender)
        {
            var           engine        = (IAutomationEngineInstance)sender;
            string        windowName    = v_WindowName.ConvertUserVariableToString(engine);
            int           timeout       = Int32.Parse(v_Timeout);
            DateTime      timeToEnd     = DateTime.Now.AddSeconds(timeout);
            List <IntPtr> targetWindows = new List <IntPtr>();

            while (timeToEnd >= DateTime.Now)
            {
                try
                {
                    if (engine.IsCancellationPending)
                    {
                        break;
                    }
                    targetWindows = User32Functions.FindTargetWindows(windowName);
                    if (targetWindows.Count == 0)
                    {
                        throw new Exception("Window Not Yet Found... ");
                    }
                    break;
                }
                catch (Exception)
                {
                    engine.ReportProgress($"Window '{windowName}' Not Yet Found... " + (timeToEnd - DateTime.Now).Minutes + "m, " + (timeToEnd - DateTime.Now).Seconds + "s remain");
                    Thread.Sleep(500);
                }
            }
            targetWindows = User32Functions.FindTargetWindows(windowName);
            //loop each window
            foreach (var targetedWindow in targetWindows)
            {
                User32Functions.CloseWindow(targetedWindow);
            }
        }