private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            s_windowHandle = new System.Windows.Interop.WindowInteropHelper(Application.Current.MainWindow).Handle;
            System.Windows.Interop.HwndSource.FromHwnd(s_windowHandle).AddHook(RunOnUiThread);

            s_mainWin = this;
            this.comboBoxRecordedUi.ItemsSource = RecordedUiTask.s_listRecordedUi;
            this.treeUiPath.ItemsSource         = UiTreeNode.s_uiTreeNodes;

            ConstVariables.InitVk2StringMap();

            AppInsights.LogEvent("Window_Loaded");
        }
        public static List <string> GetDecodedKeyboardInput(string strBase64, bool bCapsLock, bool bNumLock, bool bScrollLock)
        {
            byte[] data = Convert.FromBase64String(strBase64);

            int  i     = 0;
            bool shift = false;

            StringBuilder sb    = new StringBuilder();
            List <string> lines = new List <string>();

            int nCtrlKeyDown = 0;

            while (i < data.Length / 2)
            {
                int n1 = i * 2;
                int n2 = i * 2 + 1;
                i++;

                bool        bIsKeyDown = data[n1] == 0;
                VirtualKeys vk         = (VirtualKeys)data[n2];

                char ch = ConstVariables.Vk2char((int)vk, shift || bCapsLock);

                if (bIsKeyDown) //Keydown
                {
                    if (char.IsControl(ch))
                    {
                        nCtrlKeyDown++;

                        if (nCtrlKeyDown == 1 && sb.Length > 0)
                        {
                            lines.Add("\"" + sb.ToString() + "\"");
                            sb.Clear();
                        }

                        string vkStr     = vk.ToString();
                        string vkSendKey = ConstVariables.Vk2string(vkStr);
                        if (nCtrlKeyDown == 1)
                        {
                            sb.Append("Keys." + vkSendKey);
                        }
                        else
                        {
                            sb.Append(" + Keys." + vkSendKey);
                        }
                    }
                    else if (ch != 0)
                    {
                        string strToAppend = ch.ToString();
                        if (ch == '\\')
                        {
                            strToAppend += "\\";
                        }

                        if (nCtrlKeyDown > 0)
                        {
                            sb.Append(" + \"" + strToAppend + "\"");
                        }
                        else
                        {
                            sb.Append(strToAppend);
                        }
                    }
                }
                else //Keyup
                {
                    if (char.IsControl(ch))
                    {
                        nCtrlKeyDown--;

                        string vkStr     = vk.ToString();
                        string vkSendKey = ConstVariables.Vk2string(vkStr);

                        if (nCtrlKeyDown == 0)
                        {
                            lines.Add(sb.ToString() + " + Keys." + vkSendKey);
                            sb.Clear();
                        }
                        else
                        {
                            sb.Append(" + Keys." + vkSendKey);
                        }
                    }
                }
            }

            if (sb.Length > 0)
            {
                lines.Add("\"" + sb.ToString() + "\"");
            }

            return(lines);
        }