示例#1
0
        public static void GetMenuProgram(String Menu)
        {
            var options = Menu.Split(',');

            LogProceso("Invocando el programa del menú: " + Menu);
            foreach (var option in options)
            {
                EhllapiWrapper.SetCursorPos(GetWSPosition(22, 7));
                EhllapiWrapper.Wait();
                EhllapiWrapper.SendStr(option);
                EhllapiWrapper.Wait();
                EhllapiWrapper.SendStr("@E");
                EhllapiWrapper.Wait();
            }
        }
 private void sendStr_Click(object sender, System.EventArgs e)
 {
     EhllapiWrapper.SendStr(this.txtString.Text);
 }
示例#3
0
        public void SendStr(string param)
        {
            String ReadyKey = ConfigurationManager.AppSettings["ReadKey"].ToString().Trim();

            if (ReadyKey.Equals("SI") == true)
            {
                Console.ReadKey();
            }
            var LogStr = param;

            switch (param)
            {
            case "@A": LogStr = "Alt"; break;

            case "@$": LogStr = "Alt Cursor"; break;

            case "@A@Q": LogStr = "AEhllapiFuncntion"; break;

            case "@<": LogStr = "Backspace"; break;

            case "@B": LogStr = "Backtab(Left Tab)"; break;

            case "@C": LogStr = "Clear"; break;

            case "@A@Y": LogStr = "Cmd(function) Key"; break;

            case "@V": LogStr = "Cursor Down"; break;

            case "@L": LogStr = "Cursor Left"; break;

            case "@Z": LogStr = "Cursor Right"; break;

            case "@A@J": LogStr = "Cursor Select"; break;

            case "@U": LogStr = "Cursor Up"; break;

            case "@D": LogStr = "Delete"; break;

            case "@S@x": LogStr = "Dup "; break;

            case "@q": LogStr = " End"; break;

            case "@E": LogStr = " Enter"; break;

            case "@F": LogStr = " Erase EOF"; break;

            case "@A@F": LogStr = " Erase Input"; break;

            case "@A@E": LogStr = " Field Exit"; break;

            case "@S@y": LogStr = " Field Mark"; break;

            case "@A@-": LogStr = " Field -"; break;

            case "@A@+": LogStr = " Field +"; break;

            case "@H": LogStr = " Help"; break;

            case "@A@X": LogStr = " Hexadecimal"; break;

            case "@0": LogStr = " Home"; break;

            case "@I": LogStr = " Insert"; break;

            case "@A@I": LogStr = " Insert Toggle"; break;

            case "@P": LogStr = " Local Print"; break;

            case "@N": LogStr = " New Line"; break;

            case "@u": LogStr = " Page Up"; break;

            case "@v": LogStr = " Page Down"; break;

            case "@A@t": LogStr = " Print(PC)"; break;

            case "@A@T": LogStr = " Print Screen"; break;

            case "@A@<": LogStr = " Record Backspace"; break;

            case "@R": LogStr = " Reset"; break;

            case "@S": LogStr = " Shift"; break;

            case "@A@H": LogStr = " Sys Request"; break;

            case "@T": LogStr = " Tab(Right Tab)"; break;

            case "@A@C": LogStr = " Test"; break;

            case "@x": LogStr = " PA1 "; break;

            case "@y": LogStr = " PA2 "; break;

            case "@z": LogStr = " PA3"; break;

            case "@+": LogStr = " PA4"; break;

            case "@%": LogStr = " PA5 "; break;

            case "@&": LogStr = " PA6 "; break;

            case "@'": LogStr = " PA7 "; break;

            case "@(": LogStr = " PA8 "; break;

            case "@)": LogStr = " PA9 "; break;

            case "@*": LogStr = " PA10 "; break;

            case "@1": LogStr = " PF1 / F1"; break;

            case "@2": LogStr = " PF2 / F2"; break;

            case "@3": LogStr = " PF3 / F3"; break;

            case "@4": LogStr = " PF4 / F4"; break;

            case "@5": LogStr = " PF5 / F5"; break;

            case "@6": LogStr = " PF6 / F6"; break;

            case "@7": LogStr = " PF7 / F7"; break;

            case "@8": LogStr = " PF8 / F8"; break;

            case "@9": LogStr = " PF9 / F9"; break;

            case "@a": LogStr = " PF10 / F10"; break;

            case "@b": LogStr = " PF11 / F11"; break;

            case "@c": LogStr = " PF12 / F12"; break;

            case "@d": LogStr = " PF13 / F13"; break;

            case "@e": LogStr = " PF14 / F14"; break;

            case "@f": LogStr = " PF15 / F15"; break;

            case "@g": LogStr = " PF16 / F16"; break;

            case "@h": LogStr = " PF17 / F17"; break;

            case "@i": LogStr = " PF18 / F18"; break;

            case "@j": LogStr = " PF19 / F19"; break;

            case "@k": LogStr = " PF20 / F20"; break;

            case "@l": LogStr = " PF21 / F21"; break;

            case "@m": LogStr = " PF22 / F22"; break;

            case "@n": LogStr = " PF23 / F23"; break;

            case "@o": LogStr = " PF24 / F24"; break;

            default: LogStr = param; break;
            }
            EhllapiWrapper.SendStr(param);
            Methods.LogProceso("Se envió el parámetro:\t " + param);
            EhllapiWrapper.Wait();
        }
示例#4
0
        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);
        }