private static string GetSLLauncherCommand() { var desktopPath = string.Empty; var startMenuPath = string.Empty; var slLauncherCmmand = string.Empty; using (dynamic wShell = AutomationFactory.CreateObject("WScript.Shell")) { desktopPath = wShell.SpecialFolders("Desktop"); startMenuPath = wShell.SpecialFolders("Programs"); } using (dynamic shell = AutomationFactory.CreateObject("Shell.Application")) { dynamic desktopItems = shell.NameSpace(desktopPath).Items(); dynamic startMenuItems = shell.NameSpace(startMenuPath).Items(); FindApplicationInFolder(ref slLauncherCmmand, desktopItems); if (string.IsNullOrEmpty(slLauncherCmmand)) { FindApplicationInFolder(ref slLauncherCmmand, startMenuItems); } } return(slLauncherCmmand); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void ThreeCriteria_ThreeElements_NoMatch_NameAutomaitonIdClassName() { // Arrange var hashtable = new Hashtable(); hashtable.Add("NAME", "*aaa*"); hashtable.Add("AUTOMATIONID", "*id*"); hashtable.Add("CLASS", "cl*ss"); // Act bool result = RealCodeCaller.GetResult_IsStepActive( new Hashtable[] { hashtable }, AutomationFactory.GetUiEltCollection( new[] { FakeFactory.GetAutomationElementExpected(ControlType.Button, "aa1aa", "auId", "clas", string.Empty), FakeFactory.GetAutomationElementExpected(ControlType.Button, "aa2aa3aa", "Id", "cl____s", string.Empty), FakeFactory.GetAutomationElementExpected(ControlType.Button, "a4a5abbb", "iDrweqrqw", @"/ss", string.Empty) }) ); // Assert MbUnit.Framework.Assert.AreEqual(false, result); Assert.Equal(false, result); }
private static bool GetOutlook() { try { // If GetObject throws an exception, then Outlook is // either not running or is not available. outlook = AutomationFactory.GetObject("Outlook.Application"); return(true); } catch { try { // Start Outlook and display the Inbox, but minimize // it to avoid hiding the running application. outlook = AutomationFactory.CreateObject("Outlook.Application"); outlook.Session.GetDefaultFolder(6).Display(); // 6 = Inbox outlook.ActiveWindow.WindowState = 1; // minimized return(true); } catch { // Outlook is unavailable. return(false); } } }
partial void CreateWordDocPrinter_Execute() { if (AutomationFactory.IsAvailable) { try { //Copy the word template file to 'My Documents' SaveTemplateToMyDocuments(); string path = Environment.GetFolderPath( Environment.SpecialFolder.MyDocuments) + @"\LetterTemplate.dotx"; using (dynamic wordApp = AutomationFactory.CreateObject("Word.Application")) { dynamic wordDoc = wordApp.Documents.Open( path); wordDoc.Bookmarks("DepartmentName").Range.InsertAfter( Department.DepartmentName); wordApp.PrintOut(); wordDoc.Close(0); } } catch (Exception ex) { throw new InvalidOperationException("Failed to create letter.", ex); } } }
private static void Main(string[] args) { // 20131114 AutomationFactory.Init(); // 20121003 SpyModes currentMode = SpyModes.uIAutomationSpy; if (null != args && 0 < args.Length) { switch (Convert.ToInt32(args[0].Trim())) { case (int)SpyModes.uIAutomationSpy: currentMode = SpyModes.uIAutomationSpy; break; case (int)SpyModes.seleniumSpy: currentMode = SpyModes.seleniumSpy; break; // default: // // break; } } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new SpyForm(currentMode)); }
private void DownloadPDFScript() { WebClient a = new WebClient(); a.OpenReadAsync(new Uri(DownloadPDFScriptFileNameString, UriKind.Relative)); a.OpenReadCompleted += (object sender1, OpenReadCompletedEventArgs e1) => { StreamReader reader = new StreamReader(e1.Result); string VBSContents = reader.ReadToEnd(); reader.Close(); if (AutomationFactory.IsAvailable) { using (dynamic fso = AutomationFactory.CreateObject("Scripting.FileSystemObject")) { if (!fso.FolderExists(TempFolderPathString)) { fso.CreateFolder(TempFolderPathString); } dynamic txtFile = fso.CreateTextFile(TempFolderPathString + DownloadPDFScriptFileNameString); txtFile.WriteLine(VBSContents); txtFile.close(); } } }; }
private void Init() { try { if (App.Current.InstallState != InstallState.Installed) { updateDetailLogLabel("\nAlt-Click to install to local machine"); } if (AutomationFactory.IsAvailable) { using (dynamic shell = AutomationFactory.CreateObject("WScript.Shell")) { shell.Run("screenshot.jar -e", 0); } } else { updateDetailLogLabel("\nUnable to launch, please run java -jar screenshot.jar -d for device and java -jar screenshot.jar -e for emulator"); } SocketAsyncEventArgs args = new SocketAsyncEventArgs(); args.RemoteEndPoint = remoteEndPoint; args.Completed += new EventHandler <SocketAsyncEventArgs>(OnConnect); socket.ConnectAsync(args); } catch (Exception exp) { updateDetailLogLabel("\n" + exp.Message); } }
private void btnCreate_Click(object sender, RoutedEventArgs e) { // Code below will throw System.UnauthorizedAccessException //using (StreamWriter writer = File.CreateText("C:\\Temp.txt")) //{ // writer.WriteLine("Some text"); //} if (AutomationFactory.IsAvailable) { // Interesting, I can simply try to dispose a dynamic object without checking whether it has implemented IDisposible:) using (dynamic fso = AutomationFactory.CreateObject("Scripting.FileSystemObject")) { if (!fso.FolderExists(folderPath)) { fso.CreateFolder(folderPath); } dynamic txtFile = fso.CreateTextFile(filePath); txtFile.WriteLine("Some text..."); txtFile.close(); } ShowManipulationResult(filePath + " was created.."); } }
public static void EjecutaEXE(string ruta) { using (dynamic shell = AutomationFactory.CreateObject("WScript.shell")) { shell.Run(@ruta); } }
public void SetUp() { UnitTestingHelper.PrepareUnitTestDataStore(); // 20140227 AutomationFactory.InitUnitTests(); }
private void InitCardObj() { if (obj == null) { obj = AutomationFactory.CreateObject("HJIC.HJICCtrl.1"); } }
public UpperBathroomConfiguration( CCToolsDeviceService ccToolsBoardService, IDeviceRegistryService deviceService, ISchedulerService schedulerService, IAreaRegistryService areaService, ISettingsService settingsService, AutomationFactory automationFactory, ActuatorFactory actuatorFactory, SensorFactory sensorFactory, IMessageBrokerService messageBroker, IDeviceMessageBrokerService deviceMessageBrokerService, ILogService logService) { _messageBroker = messageBroker; _deviceMessageBrokerService = deviceMessageBrokerService; _logService = logService; _ccToolsBoardService = ccToolsBoardService ?? throw new ArgumentNullException(nameof(ccToolsBoardService)); _deviceService = deviceService ?? throw new ArgumentNullException(nameof(deviceService)); _schedulerService = schedulerService ?? throw new ArgumentNullException(nameof(schedulerService)); _areaService = areaService ?? throw new ArgumentNullException(nameof(areaService)); _settingsService = settingsService ?? throw new ArgumentNullException(nameof(settingsService)); _automationFactory = automationFactory ?? throw new ArgumentNullException(nameof(automationFactory)); _actuatorFactory = actuatorFactory ?? throw new ArgumentNullException(nameof(actuatorFactory)); _sensorFactory = sensorFactory ?? throw new ArgumentNullException(nameof(sensorFactory)); _messageBroker = messageBroker ?? throw new ArgumentNullException(nameof(sensorFactory)); }
public BJICCard(bool isInit) { if (isInit) { obj = AutomationFactory.CreateObject("YLIC.YLICCtrl.1"); } }
protected override void BeginProcessing() { var command = AutomationFactory.GetCommand <GetDesktopCommand>(this); command.Execute(); }
public static void OpenWindow(string url, int width = 1100, int height = 600) { string host = Application.Current.Host.Source.Host; int port = Application.Current.Host.Source.Port; Uri uri = new Uri(String.Format("http://{0}:{1}/{2}", host, port, url)); if (!Application.Current.IsRunningOutOfBrowser) { System.Windows.Browser.HtmlPopupWindowOptions options = new System.Windows.Browser.HtmlPopupWindowOptions(); options.Resizeable = true; options.Width = width; options.Height = height; options.Menubar = true; options.Directories = true; options.Toolbar = true; options.Status = true; System.Windows.Browser.HtmlPage.PopupWindow(uri, "_blank", options); //System.Windows.Browser.HtmlPage.Window.Navigate(uri); } else { //WebBrowserBridge.OpenURL(uri, "_blank"); using (var shell = AutomationFactory.CreateObject("WScript.Shell")) { shell.Run("iexplore.exe " + uri.AbsoluteUri); } } }
/// <summary> /// Processes the pipeline. /// </summary> protected override void ProcessRecord() { if (!CheckAndPrepareInput(this)) { return; } // foreach (IUiElement inputObject in InputObject) { // // try { // var resultElement = inputObject.InvokeContextMenu(this, X, Y); // // return the context menu window // WriteObject(this, resultElement); // } catch { // WriteError( // this, // "Failed to invoke context menu on this element", // "couldNotClick", // ErrorCategory.InvalidResult, // true); // } // // } var command = AutomationFactory.GetCommand <InvokeControlContextMenuCommand>(this); command.Execute(); }
//Listing 11-9. Opening files in their default applications partial void OpenFileFromDatabase_Execute() { try { if ((AutomationFactory.IsAvailable)) { //this is where we'll save the file string fullFilePath = System.IO.Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), IssueDocument.DocumentName); byte[] fileData = IssueDocument.IssueFile.ToArray(); if ((fileData != null)) { using (FileStream fs = new FileStream( fullFilePath, FileMode.OpenOrCreate, FileAccess.Write)) { fs.Write(fileData, 0, fileData.Length); fs.Close(); } } dynamic shell = AutomationFactory.CreateObject("Shell.Application"); shell.ShellExecute(fullFilePath); } } catch (Exception ex) { this.ShowMessageBox(ex.ToString()); } }
public void addKey(string key) { using (dynamic shell = AutomationFactory.CreateObject("WScript.Shell")) { shell.RegWrite(keyPath + "key", key, "REG_SZ"); } registered = getRegKey().checkKey(); }
/// <summary> /// Processes the pipeline. /// </summary> protected override void ProcessRecord() { CheckCmdletParameters(); var command = AutomationFactory.GetCommand <GetWindowCommand>(this); command.Execute(); }
public static void InitForPowerShell() { AutomationFactory.InitUnitTests(); Preferences.UseElementsPatternObjectModel = true; Preferences.UseElementsSearchObjectModel = true; Preferences.UseElementsCurrent = true; Preferences.UseElementsCached = false; }
public StoreroomConfiguration( IAreaService areaService, SynonymService synonymService, IDeviceService deviceService, CCToolsBoardService ccToolsBoardService, ITimerService timerService, ITwitterClientService twitterClientService, AutomationFactory automationFactory, ActuatorFactory actuatorFactory, SensorFactory sensorFactory) { if (areaService == null) { throw new ArgumentNullException(nameof(areaService)); } if (synonymService == null) { throw new ArgumentNullException(nameof(synonymService)); } if (deviceService == null) { throw new ArgumentNullException(nameof(deviceService)); } if (ccToolsBoardService == null) { throw new ArgumentNullException(nameof(ccToolsBoardService)); } if (timerService == null) { throw new ArgumentNullException(nameof(timerService)); } if (twitterClientService == null) { throw new ArgumentNullException(nameof(twitterClientService)); } if (automationFactory == null) { throw new ArgumentNullException(nameof(automationFactory)); } if (actuatorFactory == null) { throw new ArgumentNullException(nameof(actuatorFactory)); } if (sensorFactory == null) { throw new ArgumentNullException(nameof(sensorFactory)); } _areaService = areaService; _synonymService = synonymService; _deviceService = deviceService; _ccToolsBoardService = ccToolsBoardService; _timerService = timerService; _twitterClientService = twitterClientService; _automationFactory = automationFactory; _actuatorFactory = actuatorFactory; _sensorFactory = sensorFactory; }
public UpperBathroomConfiguration( CCToolsBoardService ccToolsBoardService, IDeviceService deviceService, ISchedulerService schedulerService, IAreaService areaService, ISettingsService settingsService, SynonymService synonymService, AutomationFactory automationFactory, ActuatorFactory actuatorFactory, SensorFactory sensorFactory) { if (ccToolsBoardService == null) { throw new ArgumentNullException(nameof(ccToolsBoardService)); } if (deviceService == null) { throw new ArgumentNullException(nameof(deviceService)); } if (schedulerService == null) { throw new ArgumentNullException(nameof(schedulerService)); } if (areaService == null) { throw new ArgumentNullException(nameof(areaService)); } if (settingsService == null) { throw new ArgumentNullException(nameof(settingsService)); } if (synonymService == null) { throw new ArgumentNullException(nameof(synonymService)); } if (automationFactory == null) { throw new ArgumentNullException(nameof(automationFactory)); } if (actuatorFactory == null) { throw new ArgumentNullException(nameof(actuatorFactory)); } if (sensorFactory == null) { throw new ArgumentNullException(nameof(sensorFactory)); } _ccToolsBoardService = ccToolsBoardService; _deviceService = deviceService; _schedulerService = schedulerService; _areaService = areaService; _settingsService = settingsService; _synonymService = synonymService; _automationFactory = automationFactory; _actuatorFactory = actuatorFactory; _sensorFactory = sensorFactory; }
protected override void BeginProcessing() { // UiaHelper.ShowBanner(Message); var command = AutomationFactory.GetCommand <ShowBannerCommand>(this); command.Execute(); }
private static void StartRelevantAutomationHandlers(HubEvent evt) { // Get a reference to the automation var automations = AutomationFactory.GetAutomations(evt, _hub); foreach (IAutomation automation in automations) { // If this automation is already running, cancel all running instances _taskManager.CancelRunningInstances(automation.GetType(), evt.DeviceId); // Start a task to handle the automation and a CancellationToken Source // so we can cancel it later. CancellationTokenSource cts = new CancellationTokenSource(); Func <Task> handleTask = async() => { var startedTime = DateTime.Now; Console.WriteLine($"{DateTime.Now} {automation} event: {evt.DescriptionText}"); using (var operation = _telemetryClient.StartOperation <RequestTelemetry>(automation.ToString())) { _telemetryClient.TrackEvent("Automation Started", evt.GetDictionary()); try { // This runs the Handle method on the automation class await automation.Handle(cts.Token); } catch (TaskCanceledException) { TimeSpan executionTime = DateTime.Now - startedTime; _telemetryClient.TrackEvent($"Automation Cancelled", new Dictionary <string, string>() { { "WaitTime", executionTime.TotalSeconds.ToString() }, }); Console.WriteLine($"{DateTime.Now} {automation} event from {startedTime} cancelled."); } catch (Exception ex) { operation.Telemetry.Success = false; _telemetryClient.TrackException(ex); Console.WriteLine($"{DateTime.Now} {automation} {ex} {ex.Message}"); } } }; // Ready... go handle it! Task work = Task.Run(handleTask, cts.Token); // Hold on to the task and its cancellation token source for later. _taskManager.Track(work, cts, automation.GetType(), evt.DeviceId); } // Let's take this opportunity to get rid of any completed tasks. _taskManager.RemoveCompletedTasks(); }
private void btnClose_Click(object sender, RoutedEventArgs e) { if (AutomationFactory.IsAvailable) { using (var wScript = AutomationFactory.CreateObject("WScript.Shell")) { wScript.Run(@"cmd /k taskkill /IM sllauncher.exe & exit", 0); } } }
void fe_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { using (dynamic shell = AutomationFactory.CreateObject("WScript.Shell")) { shell.SendKeys("{TAB}"); } } }
private void cmdRunProcess_Click(object sender, RoutedEventArgs e) { if (TestForComSupport()) { using (dynamic shell = AutomationFactory.CreateObject("WScript.Shell")) { shell.Run("calc.exe"); } } }
public override void Execute() { var cmdlet = (ConvertToUiaSearchCriteriaCommand)Cmdlet; var converter = AutomationFactory.GetObject <ElementToSearchCriteriaConverter>(); // foreach (IUiElement element in cmdlet.InputObject) { // WriteObject(this, ConvertElementToSearchCriteria(element)); // } }
public override void Open() { if (!string.IsNullOrEmpty(FileName)) { using (dynamic shell = AutomationFactory.CreateObject("WScript.Shell")) { shell.Run(FileName); } } }
private void btnExcel_Click(object sender, RoutedEventArgs e) { //Abrir o Excel dynamic excel; //Criando uma novo aplicação Excel excel = AutomationFactory.CreateObject("Excel.Application"); //Deixando a aplicação visível excel.Visible = true; // Criando um novo arquivo para a aplicação // Lembrando que um workbook é um conjunto de planilhas dynamic workbook = excel.workbooks; workbook.Add(); // Pega a planilha que acabamos de criar dynamic sheet = excel.ActiveSheet; // Criando o título sheet.Cells[1, 1].Value = "Exporta Cubo"; // Fonte negrito sheet.Cells[1, 1].Font.Bold = true; // Mesclando as celulas sheet.Range("A1:C1").Merge(); // Centralizando o alinhamento horizontal sheet.Range("A1:C1").HorizontalAlignment = -4108; // Criando as colunas (lembrando as celulas das planilhas começam com o índice 1 for (int coluna = 1; coluna <= dgCliente.Columns.Count; coluna++) { sheet.Cells[3, coluna].Value = dgCliente.Columns[coluna - 1].Header; sheet.Cells[3, coluna].Font.Bold = true; // Cor do Interior: Cinza sheet.Cells[3, coluna].Interior.Color = 14540253; } // Criando as linhas int linha = 4; foreach (AprReprCursoDisc apr in dgCliente.ItemsSource) { sheet.Cells[linha, 1].Value = apr.Curso; sheet.Cells[linha, 2].Value = apr.Disciplina; sheet.Cells[linha, 3].Value = apr.Ano; sheet.cells[linha, 4].value = apr.Aprovados; sheet.cells[linha, 5].value = apr.Reprovados; // Se o indice da linha for par, a cor será verde // caso contrário a cor será azul sheet.Cells[linha, 1].Interior.Color = sheet.Cells[linha, 2].Interior.Color = sheet.Cells[linha, 3].Interior.Color = (linha % 2 == 0) ? 13434828 : 16772300; linha++; } }