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); }
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); } }
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); } }
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); } }
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); } }