Beispiel #1
0
 protected override void Evaluate(int spreadMax, bool enabled)
 {
     if (enabled)
     {
         // To support old keyboard node
         if (FLegacyKeyStringIn.SliceCount > 0)
         {
             var keys = FLegacyKeyStringIn.Select(keyAsString => LegacyKeyboardHelper.StringToVirtualKeycode(keyAsString));
             FKeyboardIn.SliceCount = 1;
             FKeyboardIn[0]         = new KeyboardState(keys);
         }
         if (FKeyboardIn.SliceCount > 0)
         {
             var currentKeyboardIn = FKeyboardIn[0] ?? KeyboardState.Empty;
             if (currentKeyboardIn != FLastKeyboardIn)
             {
                 var modifierKeys = currentKeyboardIn.ModifierKeys.Select(k => (VirtualKeyCode)k);
                 var keys         = currentKeyboardIn.KeyCodes.Select(k => (VirtualKeyCode)k).Except(modifierKeys);
                 InputSimulator.SimulateModifiedKeyStroke(modifierKeys, keys);
             }
             FLastKeyboardIn = currentKeyboardIn;
         }
         // Works when we call GetKeyState before calling GetKeyboardState ?!
         //if (FHost.IsRunningInBackground)
         //    FKeysOut[0] = KeyboardState.CurrentAsync;
         //else
         var keyboard = KeyboardState.Current;
         if (keyboard != KeyboardState.Empty && keyboard == FLastKeyboard)
         {
             // Keyboard stayed the same
             if (FStopwatch.ElapsedMilliseconds > 500)
             {
                 // Simulate key repeat by generating a new keyboard with different time code
                 var time         = FStopwatch.ElapsedMilliseconds / 50;
                 var isNewKeyDown = time != FKeyboardOut[0].Time;
                 FKeyboardOut[0] = new KeyboardState(keyboard.KeyCodes, keyboard.CapsLock, (int)time);
                 // Simulate legacy output
                 if (isNewKeyDown)
                 {
                     FLegacyKeyBufferOut.AssignFrom(FKeyDowns);
                 }
                 else
                 {
                     FLegacyKeyBufferOut.SliceCount = 1;
                     FLegacyKeyBufferOut[0]         = string.Empty;
                 }
                 // Evaluate our split plugin
                 FKeyboardSplitNode.Evaluate(spreadMax);
             }
             else
             {
                 // Simulate legacy output
                 FLegacyKeyBufferOut.SliceCount = 1;
                 FLegacyKeyBufferOut[0]         = string.Empty;
             }
         }
         else
         {
             FStopwatch.Restart();
             FKeyboardOut[0] = keyboard;
             // Simulate legacy output
             FLegacyKeyStringOut.AssignFrom(keyboard.KeyCodes.Select(k => LegacyKeyboardHelper.VirtualKeycodeToString(k)));
             FKeyDowns = keyboard.KeyCodes
                         .Except(FLastKeyboard.KeyCodes)
                         .Select(k => LegacyKeyboardHelper.VirtualKeycodeToString(k))
                         .ToList();
             if (FKeyDowns.Count > 0)
             {
                 FLegacyKeyBufferOut.AssignFrom(FKeyDowns);
             }
             else
             {
                 FLegacyKeyBufferOut.SliceCount = 1;
                 FLegacyKeyBufferOut[0]         = string.Empty;
             }
             // Evaluate our split plugin
             FKeyboardSplitNode.Evaluate(spreadMax);
         }
         FLastKeyboard = keyboard;
     }
 }
Beispiel #2
0
        //event of recEngine "MAIN EXECUTION" area of all the commands
        private static void recEngine_SpeachRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            //if(e.Result)
            // {
            string result = e.Result.Text;

            if (Main_Engine == null)
            {
                create_MainEngine_new();
            }
            //main if
            if (result.Equals("can you please send a email for me"))
            {
                Main_Engine.Dispose();
                create_rec_new();
                email_rec_engine.RecognizeAsync(RecognizeMode.Multiple);
                email_rec_engine.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(Email_rec_engine_SpeachRecognized);
                getemaildata("chinu", "chinu");
            }
            else if (result.Equals("ok close now"))
            {
                Environment.Exit(0);
            }
            else if (result.Equals("show start menu"))
            {
                //MessageBox.Show(result.ToString());
                InputSimulator.SimulateKeyPress(VirtualKeyCode.LWIN);
            }
            else if (result.Equals("open my computer"))
            {
                InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_E);
            }
            else if (result.Equals("close start menu"))
            {
                InputSimulator.SimulateKeyPress(VirtualKeyCode.LWIN);
            }
            else if (result.Equals("close this"))
            {
                InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.MENU, VirtualKeyCode.F4);
            }
            else if (result.Equals("what is my battery level"))
            {
                string batry       = SystemInformation.PowerStatus.BatteryLifePercent.ToString("P0");
                string final_batry = "Battery Level :";
                final_batry += batry;
                Alert_Notification.Show_Notification_Alert(final_batry, Alert_Notification.AlertType.battery);
            }
            else if (result.Equals("show my battery level"))
            {
                string batry       = SystemInformation.PowerStatus.BatteryLifePercent.ToString("P0");
                string final_batry = "Battery Level :";
                final_batry += batry;
                Alert_Notification.Show_Notification_Alert(final_batry, Alert_Notification.AlertType.battery);
            }
            else if (result.Equals("what time it is"))
            {
                string time = DateTime.Now.ToString("h:mm:ss tt");
                Alert_Notification.Show_Notification_Alert(time, Alert_Notification.AlertType.battery);
            }
            else if (result.Equals("hows weather today"))
            {
                Weather_information.Show_Weather_notification("London", "GB");
            }
            else if (result.Equals("show power status"))
            {
                PowerLineStatus status = SystemInformation.PowerStatus.PowerLineStatus;
                if (status == PowerLineStatus.Offline)
                {
                    Alert_Notification.Show_Notification_Alert("Running on battery", Alert_Notification.AlertType.power_status);
                }
                else
                {
                    Alert_Notification.Show_Notification_Alert("Running on power supply", Alert_Notification.AlertType.power_status);
                }
            }
            else if (result.Equals("show internet connection status"))
            {
                int    des;
                string res = InternetGetConnectedState(out des, 0).ToString();
                if (res.Equals("True"))
                {
                    Alert_Notification.Show_Notification_Alert("Net is connected", Alert_Notification.AlertType.connection_status);
                }
                else
                {
                    Alert_Notification.Show_Notification_Alert("Internet is not working", Alert_Notification.AlertType.connection_status);
                }
            }
            //}
        }
Beispiel #3
0
        public static void sendKeys(string keys)
        {
            string[] keyArr = keys.Split('+');
            List <VirtualKeyCode> modifiers = new List <VirtualKeyCode>();
            VirtualKeyCode        key       = 0;

            foreach (string k in keyArr)
            {
                string kLower = k.ToLower();
                if (kLower == "shift")
                {
                    modifiers.Add(VirtualKeyCode.SHIFT);
                }
                else if (kLower == "ctrl")
                {
                    modifiers.Add(VirtualKeyCode.CONTROL);
                }
                else if (kLower == "alt")
                {
                    modifiers.Add(VirtualKeyCode.MENU);
                }
                else if (k.Length == 1)
                {
                    key = (VirtualKeyCode)(int)k[0];
                }
                else if (kLower == "f1")
                {
                    key = VirtualKeyCode.F1;
                }
                else if (kLower == "f2")
                {
                    key = VirtualKeyCode.F2;
                }
                else if (kLower == "f3")
                {
                    key = VirtualKeyCode.F3;
                }
                else if (kLower == "f4")
                {
                    key = VirtualKeyCode.F4;
                }
                else if (kLower == "f5")
                {
                    key = VirtualKeyCode.F5;
                }
                else if (kLower == "f6")
                {
                    key = VirtualKeyCode.F6;
                }
                else if (kLower == "f7")
                {
                    key = VirtualKeyCode.F7;
                }
                else if (kLower == "f8")
                {
                    key = VirtualKeyCode.F8;
                }
                else if (kLower == "f9")
                {
                    key = VirtualKeyCode.F9;
                }
                else if (kLower == "f10")
                {
                    key = VirtualKeyCode.F10;
                }
                else if (kLower == "f11")
                {
                    key = VirtualKeyCode.F11;
                }
                else if (kLower == "f12")
                {
                    key = VirtualKeyCode.F12;
                }
            }

            if (key == 0)
            {
                return;
            }
            InputSimulator.SimulateModifiedKeyStroke(modifiers.ToArray(), key);
        }
Beispiel #4
0
 public static SimpleReducer <State> Create()
 {
     return(new SimpleReducer <State>(() => new State()
     {
         IsScreenLight = true, MarqueeMessagesDict = new SortedDictionary <string, string>(), LoadingWindow = new LoadingWindow()
         {
             Topmost = true, WindowStartupLocation = WindowStartupLocation.CenterOwner
         }
     })
            .When <SysActions.StartHttpSystemSuccess>((state, action) => {
         state.HttpSystemIsStarted = true;
         return state;
     }).When <SysActions.StartHttpSystemFailed>((state, action) => {
         state.HttpSystemIsStarted = false;
         return state;
     }).When <SysActions.StartHttpSystem>((state, action) => {
         state.HttpSystemIsStarted = false;
         return state;
     }).When <SysActions.OpenScreen>((state, action) => {
         YUtil.OpenScreen(AssetsHelper.GetAssets().ExeNirCmd);
         state.IsScreenLight = true;
         return state;
     }).When <SysActions.CloseScreen>((state, action) => {
         YUtil.CloseScreen(AssetsHelper.GetAssets().ExeNirCmd);
         state.IsScreenLight = false;
         return state;
     }).When <SysActions.StartCloseScreenTimer>((state, action) => {
         if (state.IsStartOpenScreenTimer)
         {
             throw new Exception("请勿重复启动息屏定时器");
         }
         state.IsStartOpenScreenTimer = true;
         return state;
     }).When <SysActions.StopCloseScreenTimer>((state, action) => {
         state.IsStartOpenScreenTimer = false;
         return state;
     }).When <SysActions.ShowNotification>((state, action) => {
         state.NotificationMsg = action.Message;
         return state;
     }).When <SysActions.ShutdownApp>((state, action) => {
         App.Shutdown();
         return state;
     }).When <SysActions.RestartApp>((state, action) => {
         ActiveMqHelper.GetActiveMqService().Close();
         App.Restart();
         return state;
     }).When <SysActions.HideDesktop>((state, action) => {
         YUtil.Exec(AssetsHelper.GetAssets().ExeNirCmd, "win hide class progman ");
         return state;
     }).When <SysActions.ShowDesktop>((state, action) => {
         YUtil.Exec(AssetsHelper.GetAssets().ExeNirCmd, "win show class progman ");
         return state;
     }).When <SysActions.ReturnDesktop>((state, action) => {
         //通过快捷键的方式来显示桌面
         //http://inputsimulator.codeplex.com/
         InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_D);
         return state;
     }).When <SysActions.HideTaskBar>((state, action) => {
         YUtil.HideTaskBar();
         return state;
     }).When <SysActions.ShowTaskBar>((state, action) => {
         YUtil.ShowTaskBar();
         return state;
     }).When <SysActions.CloseLoadingSplash>((state, action) => {
         Application.Current.Dispatcher.Invoke(() => {
             try {
                 //DXSplashScreen.Close();
                 //state.LoadingWindow.Hide();
             } catch {
                 Console.WriteLine("隐藏加载框失败");
             }
         });
         return state;
     }).When <SysActions.ShowLoadingSplash>((state, action) => {
         Application.Current.Dispatcher.Invoke(() => {
             try {
                 //DXSplashScreen.Show<LoadingWindow>();
                 //state.LoadingWindow.Show();
             } catch {
                 Console.WriteLine(Resources.Show_Loading_View_Failed);
             }
         });
         return state;
     }));
 }
Beispiel #5
0
 public static void Desktop()
 {
     InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_D);
 }
        static void SendMediaCenterCommand(MCCommands cmd)
        {
            switch (cmd)
            {
            case MCCommands.Play:     // Ctrl Shift P
                InputSimulator.SimulateModifiedKeyStroke(new[] { VirtualKeyCode.CONTROL, VirtualKeyCode.SHIFT }, VirtualKeyCode.VK_P);
                break;

            case MCCommands.Pause:
                InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_P);
                break;

            case MCCommands.Stop:
                InputSimulator.SimulateModifiedKeyStroke(new[] { VirtualKeyCode.CONTROL, VirtualKeyCode.SHIFT }, VirtualKeyCode.VK_S);
                break;

            case MCCommands.Ffw:
                InputSimulator.SimulateModifiedKeyStroke(new[] { VirtualKeyCode.CONTROL, VirtualKeyCode.SHIFT }, VirtualKeyCode.VK_F);
                break;

            case MCCommands.Rew:
                InputSimulator.SimulateModifiedKeyStroke(new[] { VirtualKeyCode.CONTROL, VirtualKeyCode.SHIFT }, VirtualKeyCode.VK_B);
                break;

            case MCCommands.SkipFwd:
                InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_F);
                break;

            case MCCommands.SkipBack:
                InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_B);
                break;

            case MCCommands.Record:
                InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_R);
                break;

            case MCCommands.NavUp:
                InputSimulator.SimulateKeyPress(VirtualKeyCode.UP);
                break;

            case MCCommands.NavDown:
                InputSimulator.SimulateKeyPress(VirtualKeyCode.DOWN);
                break;

            case MCCommands.NavLeft:
                InputSimulator.SimulateKeyPress(VirtualKeyCode.LEFT);
                break;

            case MCCommands.NavRight:
                InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT);
                break;

            case MCCommands.NavBack:
                InputSimulator.SimulateKeyPress(VirtualKeyCode.BACK);
                break;

            case MCCommands.Menu:
                InputSimulator.SimulateKeyDown(VirtualKeyCode.LWIN);
                InputSimulator.SimulateKeyDown(VirtualKeyCode.MENU);
                InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN);
                InputSimulator.SimulateKeyUp(VirtualKeyCode.MENU);
                InputSimulator.SimulateKeyUp(VirtualKeyCode.LWIN);
                break;

            case MCCommands.Info:
                InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_D);
                break;

            case MCCommands.DVDMenu:
                InputSimulator.SimulateModifiedKeyStroke(new[] { VirtualKeyCode.CONTROL, VirtualKeyCode.SHIFT }, VirtualKeyCode.VK_M);
                break;

            case MCCommands.DVDAudio:
                InputSimulator.SimulateModifiedKeyStroke(new[] { VirtualKeyCode.CONTROL, VirtualKeyCode.SHIFT }, VirtualKeyCode.VK_A);
                break;

            case MCCommands.OK:
                InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN);
                break;

            case MCCommands.Clear:

                break;

            case MCCommands.Enter:
                InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN);
                break;

            case MCCommands.VolUp:
                InputSimulator.SimulateKeyPress(VirtualKeyCode.VOLUME_UP);
                break;

            case MCCommands.VolDown:
                InputSimulator.SimulateKeyPress(VirtualKeyCode.VOLUME_DOWN);
                break;

            case MCCommands.VolMute:
                InputSimulator.SimulateKeyPress(VirtualKeyCode.VOLUME_MUTE);
                break;

            case MCCommands.ChanUp:
                InputSimulator.SimulateKeyPress(VirtualKeyCode.PRIOR);
                break;

            case MCCommands.ChanDown:
                InputSimulator.SimulateKeyPress(VirtualKeyCode.NEXT);
                break;

            case MCCommands.Num0:
                InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_0);
                break;

            case MCCommands.Num1:
                InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_1);
                break;

            case MCCommands.Num2:
                InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_2);
                break;

            case MCCommands.Num3:
                InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_3);
                break;

            case MCCommands.Num4:
                InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_4);
                break;

            case MCCommands.Num5:
                InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_5);
                break;

            case MCCommands.Num6:
                InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_6);
                break;

            case MCCommands.Num7:
                InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_7);
                break;

            case MCCommands.Num8:
                InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_8);
                break;

            case MCCommands.Num9:
                InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_9);
                break;

            case MCCommands.NumHash:
                InputSimulator.SimulateTextEntry("#");
                break;

            case MCCommands.NumStar:
                InputSimulator.SimulateKeyPress(VirtualKeyCode.MULTIPLY);
                break;

            case MCCommands.Text:

                break;

            case MCCommands.TextRed:

                break;

            case MCCommands.TextGreen:

                break;

            case MCCommands.TextYellow:

                break;

            case MCCommands.TextBlue:

                break;

            case MCCommands.Subtitles:
                InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_U);
                break;

            case MCCommands.GotoLiveTV:
                InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_T);
                break;

            case MCCommands.GotoGuide:
                InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_G);
                break;

            case MCCommands.GotoRecTV:
                InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_O);
                break;

            case MCCommands.GotoPictures:
                InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_I);
                break;

            case MCCommands.GotoVideos:
                InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_E);
                break;

            case MCCommands.GotoMusic:
                InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_M);
                break;

            case MCCommands.GotoMovies:
                InputSimulator.SimulateModifiedKeyStroke(new [] { VirtualKeyCode.CONTROL, VirtualKeyCode.SHIFT }, VirtualKeyCode.VK_M);
                break;

            case MCCommands.GotoRadio:
                InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_A);
                break;


            case MCCommands.GotoExtras:
                InputSimulator.SimulateModifiedKeyStroke(new[] { VirtualKeyCode.CONTROL, VirtualKeyCode.SHIFT }, VirtualKeyCode.VK_R);
                break;

            case MCCommands.GreenButton:
                InputSimulator.SimulateKeyDown(VirtualKeyCode.LWIN);
                InputSimulator.SimulateKeyDown(VirtualKeyCode.MENU);
                InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN);
                InputSimulator.SimulateKeyUp(VirtualKeyCode.MENU);
                InputSimulator.SimulateKeyUp(VirtualKeyCode.LWIN);
                break;

            case MCCommands.Power:
                if (File.Exists(MEDIA_CENTER_PATH))
                {
                    System.Diagnostics.Process.Start(MEDIA_CENTER_PATH);
                }

                /*
                 *             SendKeyDown(VK.VK_MENU);
                 * SendKeyStroke(VK.VK_F4);
                 * SendKeyUp(VK.VK_MENU);
                 */
                break;
            }
        }
Beispiel #7
0
 public static void WindowsScreen()
 {
     InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.TAB);
 }
Beispiel #8
0
        // metodo que é chamado quando algo é reconhecido
        public void rec(object s, SpeechRecognizedEventArgs e)
        {
            // resultado do audio
            // MessageBox.Show(e.Result.Text);
            string speech = e.Result.Text;             // mostrar palavra reconhecida
            int    Num    = rnd.Next(1, 10);
            String QEvent;
            float  conf = e.Result.Confidence;



            string date         = DateTime.Now.Day.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Year.ToString(); // nomeando o arquivo com dia mes e ano
            string log_filename = "log\\" + date + ".txt";                                                                                // cria um arquivo .txt

            StreamWriter sw = File.AppendText(log_filename);

            if (File.Exists(log_filename))            // se o arquivo ja existir
            {
                sw.WriteLine(speech);                 // criar nova linha com o comando falado no log
            }
            else
            {
                sw.WriteLine(speech);
            }
            sw.Close();


            if (conf > 0.4)                     // se a confiança for maior que 0.65f
            {
                this.label1.ForeColor = Color.LawnGreen;
                this.label1.Text      = "Você Falou: " + speech;            // mostra na label1 o texto reconhecido

                if (e.Result.Text.Equals("pesquisar"))
                {
                    QEvent = speech;
                    Assistente.Fala("o que deseja pesquisar");
                    speech = string.Empty;
                }
                if (Gramaticas.mobparedeouvir.Any(x => x == speech))                 // se falar um dos comandos para parar de ouvir
                {
                    mobestaouvindo = false;
                    Assistente.Fala("ok, quando quiser falar comigo basta me chamar", "certo, ficarei aqui quieto");
                }
                else if (Gramaticas.mobvolteaouvir.Any(x => x == speech))                 // se falar um dos comandos para voltar a ouvir
                {
                    mobestaouvindo = true;
                    Assistente.Fala("ok, estou te ouvindo");
                }
                if (mobestaouvindo == true)
                {
                    switch (e.Result.Grammar.Name)                     // alterner entre as gramaticas de comandos
                    ///////////////////////////////////
                    // verificando comandos
                    //////////////////////////////////

                    {
                    case "sistema":                                                                                                                   // caso o comando esteja nos comandos de sistema

                        if (Gramaticas.perguntarhoras.Any(X => X == speech))                                                                          // se a pergunta estiver dentro da gramatica de sistema
                        {
                            carregar.perguntarhoras();                                                                                                // execultar o commando de perguntar as horas
                        }
                        else if (Gramaticas.ContarPiada.Any(X => X == speech))                                                                        // se a pergunta estiver dentro da gramatica de sistema
                        {
                            System.Diagnostics.Process.Start(@"E:\programação\mob assistente\mob\visualstudio\mob\mob\bin\Debug\scripts\Piadas.vbs"); // execultar o commando de perguntar data
                        }
                        else if (Gramaticas.perguntardata.Any(X => X == speech))                                                                      // se a pergunta estiver dentro da gramatica de sistema
                        {
                            carregar.perguntardata();                                                                                                 // execultar o commando de perguntar data
                        }
                        else if (Gramaticas.minimizarmob.Any(X => X == speech))                                                                       // se a pergunta estiver dentro da gramatica de sistema
                        {
                            MinimizarAssistente();                                                                                                    // execultar o commando para minimizar assistente
                        }
                        else if (Gramaticas.maximizarmob.Any(X => X == speech))                                                                       // se a pergunta estiver dentro da gramatica de sistema
                        {
                            maximizarassistente();                                                                                                    // execultar o commando para maximizar assistente
                        }
                        else if (Gramaticas.mudarvoz.Any(X => X == speech))                                                                           // se a pergunta estiver dentro da gramatica de sistema
                        {
                            if (selecionarVoz == null || selecionarVoz.IsDisposed == true)
                            {
                                selecionarVoz = new SelecionarVoz();                                         // execultar o commando para alterar a voz
                            }
                            selecionarVoz.Show();
                        }
                        else if (Gramaticas.AdcionarNovoComando.Any(X => X == speech))                                 // se a pergunta estiver dentro da gramatica de sistema
                        {
                            if (Application.OpenForms.OfType <AdicionarComandos>().Count() > 0)
                            {
                                Assistente.Fala("O painel de comandos já esta aberto");
                                adicionarComandos.Focus();
                            }
                            else
                            {
                                Assistente.Fala("abrindo painel de comandos");
                                adicionarComandos = new AdicionarComandos();
                                adicionarComandos.Show();
                            }
                            //adicionarComandos = new AdicionarComandos();
                            //Assistente.Fala("abrindo painel de comandos");
                            //adicionarComandos.Show(); // execultar o commando para mostrar o painel de comandos
                        }
                        else if (Gramaticas.abrirprograma.Any(X => X == speech)) // se a pergunta estiver dentro da gramatica de sistema
                        {
                            switch (speech)                                      // caso eu fale
                            {
                            case "Abrir Navegador":
                                navegador = new Navegador();
                                Assistente.Fala("abrindo", "abrindo mob explore");
                                navegador.Show();
                                break;

                            case "Navegador":
                                navegador = new Navegador();
                                Assistente.Fala("abrindo", "abrindo navegador");
                                navegador.Show();
                                break;

                            case "Abrir Media Player":
                                mediaPlayer = new MediaPlayer();
                                Assistente.Fala("abrindo", "mob player esta aberto");
                                mediaPlayer.Show();
                                break;

                            case "Media Player":
                                mediaPlayer = new MediaPlayer();
                                Assistente.Fala("abrindo", "abrindo mob player");
                                mediaPlayer.Show();
                                break;
                            }
                        }
                        else if (Gramaticas.ComandosPersonalizados.Any(X => X == speech)) // se a pergunta estiver dentro da gramatica de sistema
                        {
                            switch (speech)                                               // caso eu fale
                            {
                            case "atualizar comandos":
                                Assistente.Fala("Aguarde, avisarei quando eu terminar de atualizar");
                                LoadSpeech();
                                Assistente.Fala("Os comandos forão atualizados");
                                break;
                            }
                        }
                        else if (Gramaticas.Teclado.Any(X => X == speech))      // se a pergunta estiver dentro da gramatica de sistema
                        {
                            switch (speech)                                     // caso eu fale
                            {
                            case "Leia o texto":
                                InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_C);
                                Lertexto.Leitura();
                                break;

                            case "copiar":
                                InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_C);
                                break;

                            case "colar":
                                SimularTeclas.Colar();
                                break;
                            }
                        }
                        else if (Gramaticas.Traducao.Any(X => X == speech))     // se a pergunta estiver dentro da gramatica de sistema
                        {
                            switch (speech)                                     // caso eu fale
                            {
                            case "Traduza o texto":
                                Traducao.Traduzido();
                                break;

                            case "Leia o texto em portugues":
                                Traducao.Traduzido();
                                break;
                            }
                        }
                        else if (Gramaticas.feixarprograma.Any(X => X == speech)) // se a pergunta estiver dentro da gramatica de sistema
                        {
                            switch (speech)                                       // caso eu fale
                            {
                            case "Feixar Navegador":
                                navegador.Close();
                                Assistente.Fala("feixando", "feixando mob explore");
                                break;

                            case "Feixar Media Player":
                                mediaPlayer.Close();
                                Assistente.Fala("feixando", "feixando mob player");
                                break;

                            case "Feixar Painel de Comandos":
                                Assistente.Fala("feixando painel de comandos");
                                adicionarComandos.Close();
                                break;
                            }
                        }

                        else if (Gramaticas.ComandosMediaPlayer.Any(x => x == speech))
                        {
                            switch (speech)
                            {
                            case "Abrir Arquivo":
                                if (mediaPlayer != null)
                                {
                                    mediaPlayer.AbrirArquivo();
                                    Assistente.Fala("Selecione um arquivo");
                                }
                                else
                                {
                                    Assistente.Fala("o media player não esta aberto");
                                }
                                break;
                            }
                        }
                        else if (Gramaticas.Digitar.Any(x => x == speech))
                        {
                            switch (speech)
                            {
                            case "digitar":

                                break;
                            }
                        }
                        break;

                    case "calculos":
                        Assistente.Fala("é " + resolvercalculos.Resolver(speech), "muito fáciu. " + resolvercalculos.Resolver(speech), "essa é fáciu. " + resolvercalculos.Resolver(speech));
                        break;

                    case "Personalizados":                             // caso Personalizados
                        string comando = e.Result.Text;
                        comando = comando.Trim();
                        foreach (KeyValuePair <string, string> entry in dictCmdPersonalizados)
                        {
                            if (entry.Key == comando)
                            {
                                Assistente.Fala(entry.Value);
                            }
                        }
                        foreach (KeyValuePair <string, string> entry in dictCmdSites)
                        {
                            if (entry.Key == comando)
                            {
                                Assistente.Fala(entry.Value);
                            }
                        }
                        break;

                    default:                                         // caso padrão
                        Assistente.Fala(AIML.GetOutputChat(speech)); // pegar resposta
                        break;
                    }
                }
            }
            else
            {
                this.label1.ForeColor = Color.Red;
            }
        }
        void EndCheckLoop()
        {
            // Avoid duplicate checks by only running the check if the loop inenumerator is not null
            if (combinationCheckLoop != null)
            {
                if (doubleThumbToggle.isOn && inputFlags.HasFlag(DOFSCIIMap.DOFSCIIToggle))
                {
                    dofsciiOn = !dofsciiOn;
                    dofsciiActiveStatus.isOn = dofsciiOn;
                    inputFlags = 0;
                    return;
                }

                if (dofsciiOn)
                {
                    if (inputFlags.HasFlag(DOFSCIIMap.arrowLeft))
                    {
                        if (caps)
                        {
                            InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.SHIFT, VirtualKeyCode.LEFT);
                        }
                        else
                        {
                            InputSimulator.SimulateKeyPress(VirtualKeyCode.LEFT);
                        }
                    }
                    else if (inputFlags.HasFlag(DOFSCIIMap.arrowRight))
                    {
                        if (caps)
                        {
                            InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.SHIFT, VirtualKeyCode.RIGHT);
                        }
                        else
                        {
                            InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT);
                        }
                    }
                    else if (inputFlags.HasFlag(DOFSCIIMap.arrowUp))
                    {
                        if (caps)
                        {
                            InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.SHIFT, VirtualKeyCode.UP);
                        }
                        else
                        {
                            InputSimulator.SimulateKeyPress(VirtualKeyCode.UP);
                        }
                    }
                    else if (inputFlags.HasFlag(DOFSCIIMap.arrowDown))
                    {
                        if (caps)
                        {
                            InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.SHIFT, VirtualKeyCode.DOWN);
                        }
                        else
                        {
                            InputSimulator.SimulateKeyPress(VirtualKeyCode.DOWN);
                        }
                    }
                    else if (inputFlags.HasFlag(DOFSCIIMap.Backspace))
                    {
                        if (displayText != null && displayText.text.Length > 0)
                        {
                            displayText.text = displayText.text.Substring(0, displayText.text.Length - 1);
                        }

                        InputSimulator.SimulateKeyPress(VirtualKeyCode.BACK);
                    }
                    else if (inputFlags.HasFlag(DOFSCIIMap.Delete))
                    {
                        if (displayText.text.Length > 0)
                        {
                            displayText.text = displayText.text.Substring(0, displayText.text.Length - 1);
                        }

                        InputSimulator.SimulateKeyPress(VirtualKeyCode.DELETE);
                    }
                    else if (inputFlags.HasFlag(DOFSCIIMap.modeSwitch))
                    {
                        int newMode = (currentKeyMode == KeyMode.Alphanumeric) ? 1 : -1;
                        currentKeyMode = (KeyMode)((int)currentKeyMode + newMode);
                        alphaButtons[49].Highlight();
                        Debug.Log("Mode: " + currentKeyMode);
                    }
                    //else if (inputFlags.HasFlag(DOFSCIIMap.CapsToggle)) caps = !caps;
                    else if (inputFlags.HasFlag(DOFSCIIMap.CapsToggle))
                    {
                        caps = !caps;
                        InputSimulator.SimulateKeyPress(VirtualKeyCode.CAPITAL);
                        alphaButtons[48].HighlightToggle(caps);
                    }
                    else
                    {
                        // No special keys were pressed. The only other possibilities are combinations from either alpha mode or bracket mode.
                        // Here, we determine how many keys were pressed simultaneously to narrow down the number of checks,
                        // and then we check the possible mappings for either alpha mode or bracket mode.

                        switch (HammingWeight((int)inputFlags))
                        {
                        case 5:     // Five simultaneous keys were pressed
                            if (inputFlags.HasFlag(DOFSCIIMap.Hashtag))
                            {
                                HandleInput("#");
                                alphaButtons[43].Highlight();
                            }
                            else if (inputFlags.HasFlag(DOFSCIIMap.Ampersand))
                            {
                                HandleInput("&");
                                alphaButtons[44].Highlight();
                            }
                            else if (inputFlags.HasFlag(DOFSCIIMap.Percent))
                            {
                                HandleInput("%");
                                alphaButtons[45].Highlight();
                            }
                            else if (inputFlags.HasFlag(DOFSCIIMap.DollarSign))
                            {
                                HandleInput("$");
                                alphaButtons[46].Highlight();
                            }
                            else if (inputFlags.HasFlag(DOFSCIIMap.Caret))
                            {
                                HandleInput("^");
                                alphaButtons[47].Highlight();
                            }
                            break;

                        case 4:     // Four simultaneous keys were pressed
                            if (currentKeyMode == KeyMode.Alphanumeric)
                            {
                                if (inputFlags.HasFlag(DOFSCIIMap.Z))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_Z, "z");
                                    alphaButtons[25].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.X))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_X, "x");
                                    alphaButtons[23].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Semicolon))
                                {
                                    HandleInput(";");
                                    alphaButtons[35].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Colon))
                                {
                                    HandleInput(":");
                                    alphaButtons[36].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Period))
                                {
                                    HandleInput(".");
                                    alphaButtons[26].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Quote))
                                {
                                    HandleInput("\"");
                                    alphaButtons[37].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.QuestionMark))
                                {
                                    HandleInput("?");
                                    alphaButtons[28].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Exclamation))
                                {
                                    HandleInput("!");
                                    alphaButtons[38].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Tilde))
                                {
                                    HandleInput("~");
                                    alphaButtons[40].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Apostrophe))
                                {
                                    HandleInput("'");
                                    alphaButtons[41].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Comma))
                                {
                                    HandleInput(",");
                                    alphaButtons[27].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Underscore))
                                {
                                    HandleInput("_");
                                    alphaButtons[39].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.AccentGrave))
                                {
                                    HandleInput("`");
                                    alphaButtons[42].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.At))
                                {
                                    HandleInput("@");
                                    alphaButtons[34].Highlight();
                                }
                            }
                            else
                            {
                                if (inputFlags.HasFlag(DOFSCIIMap.WindowsKey))
                                {
                                    currentKeyMode = KeyMode.Alphanumeric;
                                    InputSimulator.SimulateKeyPress(VirtualKeyCode.LWIN);
                                    bracketButtons[19].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.BrowserBack))
                                {
                                    InputSimulator.SimulateKeyPress(VirtualKeyCode.BROWSER_BACK);
                                    bracketButtons[7].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.BrowserForward))
                                {
                                    InputSimulator.SimulateKeyPress(VirtualKeyCode.BROWSER_FORWARD);
                                    bracketButtons[17].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.VolumeDown))
                                {
                                    InputSimulator.SimulateKeyPress(VirtualKeyCode.VOLUME_DOWN);
                                    bracketButtons[8].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.VolumeUp))
                                {
                                    InputSimulator.SimulateKeyPress(VirtualKeyCode.VOLUME_UP);
                                    bracketButtons[18].Highlight();
                                }
                            }
                            break;

                        case 3:     // Three simultaneous keys were pressed
                            if (currentKeyMode == KeyMode.Alphanumeric)
                            {
                                if (inputFlags.HasFlag(DOFSCIIMap.B))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_B, "b");
                                    alphaButtons[1].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.P))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_P, "p");
                                    alphaButtons[15].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.V))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_V, "v");
                                    alphaButtons[21].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.K))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_K, "k");
                                    alphaButtons[10].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.J))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_J, "j");
                                    alphaButtons[9].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Q))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_Q, "q");
                                    alphaButtons[16].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Zero))
                                {
                                    HandleAlphaKey(VirtualKeyCode.NUMPAD0, "0");
                                    alphaButtons[50].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.One))
                                {
                                    HandleAlphaKey(VirtualKeyCode.NUMPAD1, "1");
                                    alphaButtons[51].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Two))
                                {
                                    HandleAlphaKey(VirtualKeyCode.NUMPAD2, "2");
                                    alphaButtons[52].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Three))
                                {
                                    HandleAlphaKey(VirtualKeyCode.NUMPAD3, "3");
                                    alphaButtons[53].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Four))
                                {
                                    HandleAlphaKey(VirtualKeyCode.NUMPAD4, "4");
                                    alphaButtons[54].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Five))
                                {
                                    HandleAlphaKey(VirtualKeyCode.NUMPAD5, "5");
                                    alphaButtons[55].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Six))
                                {
                                    HandleAlphaKey(VirtualKeyCode.NUMPAD6, "6");
                                    alphaButtons[56].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Seven))
                                {
                                    HandleAlphaKey(VirtualKeyCode.NUMPAD7, "7");
                                    alphaButtons[57].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Eight))
                                {
                                    HandleAlphaKey(VirtualKeyCode.NUMPAD8, "8");
                                    alphaButtons[58].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Nine))
                                {
                                    HandleAlphaKey(VirtualKeyCode.NUMPAD9, "9");
                                    alphaButtons[19].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Plus))
                                {
                                    HandleAlphaKey(VirtualKeyCode.ADD, "+");
                                    alphaButtons[30].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Minus))
                                {
                                    HandleAlphaKey(VirtualKeyCode.SUBTRACT, "-");
                                    alphaButtons[31].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Multiply))
                                {
                                    HandleAlphaKey(VirtualKeyCode.MULTIPLY, "*");
                                    alphaButtons[32].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Divide))
                                {
                                    HandleAlphaKey(VirtualKeyCode.DIVIDE, "/");
                                    alphaButtons[33].Highlight();
                                }
                            }
                            else
                            {
                                if (inputFlags.HasFlag(DOFSCIIMap.Undo))
                                {
                                    InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_Z);
                                    bracketButtons[6].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Redo))
                                {
                                    InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_Y);
                                    bracketButtons[16].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Cut))
                                {
                                    InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_X);
                                    bracketButtons[9].Highlight();
                                }
                            }

                            break;

                        case 2:     // Two simultaneous keys were pressed
                            if (currentKeyMode == KeyMode.Bracket)
                            {
                                if (inputFlags.HasFlag(DOFSCIIMap.OpenStraightBracket))
                                {
                                    HandleInput("[");
                                    bracketButtons[3].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.CloseStraightBracket))
                                {
                                    HandleInput("]");
                                    bracketButtons[13].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.StraightSlash))
                                {
                                    HandleInput("|");
                                    bracketButtons[4].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.BackSlash))
                                {
                                    HandleInput("\\");
                                    bracketButtons[14].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Copy))
                                {
                                    InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_C);
                                    bracketButtons[5].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Paste))
                                {
                                    InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_V);
                                    bracketButtons[15].Highlight();
                                }
                            }
                            else
                            {
                                if (inputFlags.HasFlag(DOFSCIIMap.F))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_F, "f");
                                    alphaButtons[6].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.N))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_N, "n");
                                    alphaButtons[13].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.D))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_D, "d");
                                    alphaButtons[3].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.C))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_C, "c");
                                    alphaButtons[2].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.R))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_R, "r");
                                    alphaButtons[17].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.S))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_S, "s");
                                    alphaButtons[18].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.T))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_T, "t");
                                    alphaButtons[19].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.H))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_H, "h");
                                    alphaButtons[7].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.L))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_L, "l");
                                    alphaButtons[11].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.M))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_M, "m");
                                    alphaButtons[12].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.W))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_W, "w");
                                    alphaButtons[22].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.G))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_G, "g");
                                    alphaButtons[6].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Space))
                                {
                                    HandleAlphaKey(VirtualKeyCode.SPACE, " ");
                                    alphaButtons[29].Highlight();
                                }
                            }
                            break;

                        case 1:     // Only one key was pressed
                            if (currentKeyMode == KeyMode.Alphanumeric)
                            {
                                if (inputFlags.HasFlag(DOFSCIIMap.A))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_A, "a");
                                    alphaButtons[0].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.E))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_E, "e");
                                    alphaButtons[4].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.I))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_I, "i");
                                    alphaButtons[8].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.O))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_O, "o");
                                    alphaButtons[14].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.U))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_U, "u");
                                    alphaButtons[20].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Y))
                                {
                                    HandleAlphaKey(VirtualKeyCode.VK_Y, "y");
                                    alphaButtons[24].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Newline))
                                {
                                    HandleAlphaKey(VirtualKeyCode.RETURN, "\n");
                                }
                            }
                            else
                            {
                                if (inputFlags.HasFlag(DOFSCIIMap.OpenParinthesis))
                                {
                                    HandleInput("(");
                                    bracketButtons[2].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.CloseParinthesis))
                                {
                                    HandleInput(")");
                                    bracketButtons[12].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.OpenAngleBracket))
                                {
                                    HandleInput("<");
                                    bracketButtons[1].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.CloseAngleBracket))
                                {
                                    HandleInput(">");
                                    bracketButtons[11].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.OpenSquigglyBracket))
                                {
                                    HandleInput("{");
                                    bracketButtons[0].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.CloseSquigglyBracket))
                                {
                                    HandleInput("}");
                                    bracketButtons[10].Highlight();
                                }
                                else if (inputFlags.HasFlag(DOFSCIIMap.Newline))
                                {
                                    HandleAlphaKey(VirtualKeyCode.RETURN, "\n");
                                }
                            }

                            break;
                        }

                        if (outputToDisplayText && displayText != null)
                        {
                            displayText.text += newCharacter;
                        }
                    }

                    StopCoroutine(combinationCheckLoop);
                    combinationCheckLoop = null;
                }
            }

            inputFlags = 0;
        }
        private void KeyboardAction(string command, string keys) //executes the code line by line.
        {
            string         keyboardkey = keys.ToUpper();
            VirtualKeyCode code;

            try
            {
                switch (command)
                {
                case "DEFAULT_DELAY":
                case "DEFAULTDELAY":
                    defaultdelay       = true;
                    defaultdelayvalue += Convert.ToInt32(keys);
                    break;

                case "DELAY":
                    CheckDefaultSleep();
                    Thread.Sleep(Convert.ToInt32(keys));
                    break;

                case "STRING":
                    CheckDefaultSleep();
                    if (isCapsEnabled == true)
                    {
                        InputSimulator.SimulateTextEntry((keys.ToUpper()));
                    }
                    else
                    {
                        InputSimulator.SimulateTextEntry(keys);
                    }
                    break;

                case "WINDOWS":
                case "GUI":
                    CheckDefaultSleep();
                    if (keyboardkey.Length > 0)
                    {
                        if (Enum.TryParse <VirtualKeyCode>("VK_" + keyboardkey, out code))
                        {
                            InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.LWIN, code);
                        }
                    }
                    else
                    {
                        InputSimulator.SimulateKeyPress(VirtualKeyCode.LWIN);
                    }

                    break;

                case "ENTER":
                    CheckDefaultSleep();
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN);
                    break;

                case "APP":
                case "MENU":
                    CheckDefaultSleep();
                    InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.SHIFT, VirtualKeyCode.F10);
                    break;

                case "SHIFT":
                    CheckDefaultSleep();
                    switch (keys)
                    {
                    case "WINDOWS":
                    case "GUI":
                        InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.SHIFT, VirtualKeyCode.LWIN);
                        break;

                    case "UPARROW":
                        InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.SHIFT, VirtualKeyCode.UP);
                        break;

                    case "DOWNARROW":
                        InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.SHIFT, VirtualKeyCode.DOWN);
                        break;

                    case "LEFTARROW":
                        InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.SHIFT, VirtualKeyCode.LEFT);
                        break;

                    case "RIGHTARROW":
                        InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.SHIFT, VirtualKeyCode.RIGHT);
                        break;

                    default:
                        if (Enum.TryParse <VirtualKeyCode>("" + keyboardkey, out code))
                        {
                            InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.SHIFT, code);
                        }
                        break;
                    }

                    break;

                case "ALT":
                    CheckDefaultSleep();
                    switch (keys)
                    {
                    case "WINDOWS":
                    case "GUI":
                        InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.LMENU, VirtualKeyCode.LWIN);
                        break;

                    case "UPARROW":
                        InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.LMENU, VirtualKeyCode.UP);
                        break;

                    case "DOWNARROW":
                        InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.LMENU, VirtualKeyCode.DOWN);
                        break;

                    case "LEFTARROW":
                        InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.LMENU, VirtualKeyCode.LEFT);
                        break;

                    case "RIGHTARROW":
                        InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.LMENU, VirtualKeyCode.RIGHT);
                        break;

                    default:
                        if (keyboardkey.Length > 1)
                        {
                            //For support for keys such as "end"
                            if (Enum.TryParse <VirtualKeyCode>("" + keyboardkey, out code))
                            {
                                InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.LMENU, code);
                            }
                        }
                        else
                        {
                            if (Enum.TryParse <VirtualKeyCode>("VK_" + keyboardkey, out code))
                            {
                                InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.LMENU, code);
                            }
                        }
                        break;
                    }
                    break;

                case "CONTROL":
                case "CTRL":
                    CheckDefaultSleep();
                    switch (keys)
                    {
                    case "ESC":
                    case "ESCAPE":
                        InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.ESCAPE);
                        break;

                    case "PAUSE":
                        InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.PAUSE);
                        break;

                    case "UPARROW":
                        InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.UP);
                        break;

                    case "DOWNARROW":
                        InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.DOWN);
                        break;

                    case "LEFTARROW":
                        InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.LEFT);
                        break;

                    case "RIGHTARROW":
                        InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.RIGHT);
                        break;

                    case "SHIFT":
                        InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.SHIFT);
                        break;

                    default:
                        if (keyboardkey.Length > 1)
                        {
                            //For support for keys such as "end"
                            if (Enum.TryParse <VirtualKeyCode>("" + keyboardkey, out code))
                            {
                                InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, code);
                            }
                        }
                        else
                        {
                            if (Enum.TryParse <VirtualKeyCode>("VK_" + keyboardkey, out code))
                            {
                                InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, code);
                            }
                        }
                        break;
                    }
                    break;

                case "TAB":
                    CheckDefaultSleep();
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.TAB);
                    break;

                case "DOWNARROW":
                case "DOWN":
                    CheckDefaultSleep();
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.DOWN);
                    break;

                case "LEFTARROW":
                case "LEFT":
                    CheckDefaultSleep();
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.LEFT);
                    break;

                case "RIGHTARROW":
                case "RIGHT":
                    CheckDefaultSleep();
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT);
                    break;

                case "UPARROW":
                case "UP":
                    CheckDefaultSleep();
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.UP);
                    break;

                case "REPLAY":
                    CheckDefaultSleep();
                    for (int i = 0; i < Convert.ToInt32(keys); i++)
                    {
                        KeyboardAction(lastCommand, lastKey);
                    }
                    break;

                case "DELETE":
                    CheckDefaultSleep();
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.DELETE);
                    break;

                case "CAPS":
                    CheckDefaultSleep();
                    isCapsEnabled = !isCapsEnabled;
                    break;

                case "SPACE":
                    CheckDefaultSleep();
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.SPACE);
                    break;

                case "PRINTSCREEN":
                    CheckDefaultSleep();
                    InputSimulator.SimulateKeyPress(VirtualKeyCode.PRINT);
                    break;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Error while trying to simulate keys. Probably UAC getting in the way. " +
                                "This toolkit cannot type when UAC is open for security reasons, try disabling UAC and running the script again ");
            }
            if (command != "REPLAY" && command != "REM") //If the last function wasn't replay/rem. Make the current command the last one
            {
                setLastCommand(command, keys);           //Used for the repeat function
            }
        }
        public static void presionarTecla(string tecla)
        {
            tecla = tecla.ToLower();
            switch (tecla)
            {
            case "a": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_A); break;

            case "bê": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_B); break;

            case "cê": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_C); break;

            case "dê": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_D); break;

            case "é": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_E); break;

            case "efe": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_F); break;

            case "gê": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_G); break;

            case "agá": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_H); break;

            case "i": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_I); break;

            case "jota": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_J); break;

            case "cá": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_K); break;

            case "ele": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_L); break;

            case "eme": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_M); break;

            case "ene": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_N); break;

            case "ó": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_O); break;

            case "pê": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_P); break;

            case "quê": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_Q); break;

            case "érre": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_R); break;

            case "ésse": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_S); break;

            case "tê": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_T); break;

            case "dáblio": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_W); break;

            case "u": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_U); break;

            case "vê": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_V); break;

            case "xis": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_X); break;

            case "ípsilon": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_Y); break;

            case "zê": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_Z); break;

            case "baixo": InputSimulator.SimulateKeyPress(VirtualKeyCode.DOWN); break;

            case "esquerda": InputSimulator.SimulateKeyPress(VirtualKeyCode.LEFT); break;

            case "anterior": InputSimulator.SimulateKeyPress(VirtualKeyCode.BROWSER_BACK); break;

            case "avançar": InputSimulator.SimulateKeyPress(VirtualKeyCode.BROWSER_FORWARD); break;

            case "enter": InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); break;

            case "tudo": InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_A); break;

            case "controlc": InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_C); break;

            case "controlv": InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_V); break;

            case "controlz": InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_Z); break;

            case "volume": InputSimulator.SimulateKeyPress(VirtualKeyCode.VOLUME_UP); break;

            case "volume1": InputSimulator.SimulateKeyPress(VirtualKeyCode.VOLUME_DOWN); break;

            case "navegador": InputSimulator.SimulateKeyPress(VirtualKeyCode.BROWSER_STOP); break;

            case "janela atual": InputSimulator.SimulateModifiedKeyStroke(new[] { VirtualKeyCode.MENU, VirtualKeyCode.SPACE }, new[] { VirtualKeyCode.VK_N }); break;

            case "nova guia e acessá-la": InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_T); break;

            case "nova janela no modo de navegação anônima": InputSimulator.SimulateModifiedKeyStroke(new[] { VirtualKeyCode.CONTROL, VirtualKeyCode.SHIFT }, new[] { VirtualKeyCode.VK_N }); break;

            case "próxima guia aberta": InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.TAB); break;

            case "guia aberta anterior": InputSimulator.SimulateModifiedKeyStroke(new[] { VirtualKeyCode.CONTROL, VirtualKeyCode.SHIFT }, new[] { VirtualKeyCode.TAB }); break;

            case "guia atual": InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_W); break;

            case "guias abertas e o navegador":     InputSimulator.SimulateModifiedKeyStroke(new[] { VirtualKeyCode.CONTROL, VirtualKeyCode.SHIFT }, new[] { VirtualKeyCode.VK_W }); break;

            case "Google Chrome": InputSimulator.SimulateModifiedKeyStroke(new[] { VirtualKeyCode.CONTROL, VirtualKeyCode.SHIFT }, new[] { VirtualKeyCode.VK_Q }); break;
            }
        }