public void Connect(string id) { EhllapiWrapper.Connect(id); EhllapiWrapper.Wait(); }
private void button1_Click(object sender, System.EventArgs e) { MessageBox.Show(EhllapiWrapper.Connect(txtSessione.Text).ToString()); }
public static Boolean OpenWS(string EmulatorURL, string SessionId, string Username, string Password, out int Id) { Console.Write("Inicializando IBS... "); string IsShowWindow = ConfigurationManager.AppSettings["ShowWindow"].ToString().Trim(); string Session = ConfigurationManager.AppSettings["SessionId"].ToString().Trim(); Process[] pcscmProcesses = Process.GetProcessesByName("pcsws"); if (pcscmProcesses.Length == 0) { Process.Start("taskkill", "/F /IM [pcsws].exe"); Process.Start("taskkill", "/F /IM [pcscm].exe"); } //Funciona correcto Process px = Process.Start(EmulatorURL); //Process px = new Process(); //try //{ // px.StartInfo = new ProcessStartInfo(EmulatorURL); // px.StartInfo.CreateNoWindow = true; // px.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; // px.Start(); //} catch (Exception e) //{ // LogProceso(e.ToString()); //} //Thread.Sleep(4000); int _i = 0; Id = 0; do { try { pcscmProcesses = Process.GetProcessesByName("pcsws"); Id = pcscmProcesses.ToList().Find(x => x.MainWindowTitle.Contains(Session)).Id; _i = 1; if (IsShowWindow.Equals("SI")) { ShowWindow(Process.GetProcessById(Id).MainWindowHandle, 2); } } #pragma warning disable CS0168 // La variable 'e' se ha declarado pero nunca se usa catch (Exception e) #pragma warning restore CS0168 // La variable 'e' se ha declarado pero nunca se usa { //throw new Exception("No se inició correctamente la sesión B"); Thread.Sleep(1000); } } while (_i == 0); Boolean isOpenWS = false; string validationPass; int i = 0; do { try { AutomationElement _0 = AutomationElement.FromHandle(px.MainWindowHandle); AutomationElementCollection _0_Descendants_1 = _0.FindAll(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "ID de usuario:")); ValuePattern etb = _0_Descendants_1[1].GetCurrentPattern(ValuePattern.Pattern) as ValuePattern; etb.SetValue(Username); AutomationElementCollection _0_Descendants_2 = _0.FindAll(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "Contraseña:")); ValuePattern etb2 = _0_Descendants_2[1].GetCurrentPattern(ValuePattern.Pattern) as ValuePattern; etb2.SetValue(Password); AutomationElementCollection _0_Descendants_3 = _0.FindAll(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "Aceptar")); var invokePattern = _0_Descendants_3[0].GetCurrentPattern(InvokePattern.Pattern) as InvokePattern; invokePattern.Invoke(); } #pragma warning disable CS0168 // La variable 'e' se ha declarado pero nunca se usa catch (Exception e) #pragma warning restore CS0168 // La variable 'e' se ha declarado pero nunca se usa { } EhllapiWrapper.Connect(SessionId); EhllapiWrapper.Wait(); EhllapiWrapper.SetCursorPos(GetWSPosition(6, 17)); EhllapiWrapper.Wait(); EhllapiWrapper.ReadScreen(GetWSPosition(6, 17), 7, out validationPass); EhllapiWrapper.Wait(); try { if (validationPass.Substring(0, 7) == "Usuario") { var ValidationMsg = ""; EhllapiWrapper.Wait(); EhllapiWrapper.Connect(SessionId); EhllapiWrapper.Wait(); EhllapiWrapper.SetCursorPos(GetWSPosition(6, 53)); EhllapiWrapper.Wait(); EhllapiWrapper.SendStr(Username); EhllapiWrapper.Wait(); EhllapiWrapper.SetCursorPos(GetWSPosition(7, 53)); EhllapiWrapper.Wait(); EhllapiWrapper.SendStr(Password); EhllapiWrapper.Wait(); EhllapiWrapper.SendStr("@E"); EhllapiWrapper.Wait(); ValidationMsg = ""; EhllapiWrapper.SetCursorPos(GetWSPosition(1, 26)); EhllapiWrapper.Wait(); EhllapiWrapper.ReadScreen(GetWSPosition(1, 26), 31, out ValidationMsg); EhllapiWrapper.Wait(); if (ValidationMsg.Substring(0, 31).Equals("Visualizar Mensajes de Programa")) { EhllapiWrapper.SendStr("@E"); EhllapiWrapper.Wait(); isOpenWS = true; } else { Console.Write("OK\n"); isOpenWS = true; } i = 1; } } #pragma warning disable CS0168 // La variable 'e' se ha declarado pero nunca se usa catch (Exception e) #pragma warning restore CS0168 // La variable 'e' se ha declarado pero nunca se usa { } } while (i == 0); return(isOpenWS); }