Exemplo n.º 1
0
        public string GetCSCode(string focusedElemName)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("// " + this.Description);

            string consoleWriteLine = "Console.WriteLine(\"" + this.Description.Replace("\"", "\\\"") + "\");";

            sb.AppendLine(consoleWriteLine);

            if (this.UiTaskName == EnumUiTaskName.LeftClick)
            {
                sb.AppendLine(GenerateCSCode.LeftClick(this, VariableName));
            }
            else if (this.UiTaskName == EnumUiTaskName.RightClick)
            {
                sb.AppendLine(GenerateCSCode.RightClick(this, VariableName));
            }
            else if (this.UiTaskName == EnumUiTaskName.LeftDblClick)
            {
                sb.AppendLine(GenerateCSCode.DoubleClick(this, VariableName));
            }
            else if (this.UiTaskName == EnumUiTaskName.MouseWheel)
            {
                sb.AppendLine(GenerateCSCode.Wheel(this, VariableName));
            }
            else if (this.UiTaskName == EnumUiTaskName.KeyboardInput)
            {
                sb.AppendLine(GenerateCSCode.SendKeys(this, focusedElemName));
            }

            return(sb.ToString());
        }
Exemplo n.º 2
0
        public void AppendKeyboardInput(string textToAppend)
        {
            byte[] data1 = Convert.FromBase64String(this.Base64Text);
            byte[] data2 = Convert.FromBase64String(textToAppend);
            byte[] data  = new byte[data1.Length + data2.Length];
            data1.CopyTo(data, 0);
            data2.CopyTo(data, data1.Length);
            this.Base64Text = Convert.ToBase64String(data);

            var           keyboardTaskDescription = GenerateCSCode.GetDecodedKeyboardInput(this.Base64Text, this.CapsLock, this.NumLock, this.ScrollLock);
            StringBuilder sb = new StringBuilder();

            foreach (var strLine in keyboardTaskDescription)
            {
                sb.Append(strLine);
            }

            this._strDescription = $"{this.UiTaskName} VirtualKeys=\"{sb.ToString()}\" CapsLock={this.CapsLock} NumLock={this.NumLock} ScrollLock={this.ScrollLock}";
        }
        public static void AddKeyboardInputTask(ref string strBase64, bool bCapsLock, bool bNumLock, bool bScrollLock)
        {
            if (string.IsNullOrEmpty(strBase64))
            {
                AppInsights.LogException("AddKeyboardInputTask", "strBase64 is null");
                return;
            }

            var keyboardTaskDescription = GenerateCSCode.GetDecodedKeyboardInput(strBase64, bCapsLock, bNumLock, bScrollLock);

            StringBuilder sb = new StringBuilder();

            foreach (var strLine in keyboardTaskDescription)
            {
                sb.Append(GenerateXPath.XmlEncode(strLine));
            }

            RecordedUiTask lastRecordedUi = null;

            lock (RecordedUiTask.s_lockRecordedUi)
            {
                if (RecordedUiTask.s_listRecordedUi.Count > 0)
                {
                    lastRecordedUi = RecordedUiTask.s_listRecordedUi.Last();
                }
            }

            if (lastRecordedUi != null && lastRecordedUi.UiTaskName == EnumUiTaskName.KeyboardInput)
            {
                lastRecordedUi.AppendKeyboardInput(strBase64);
            }
            else
            {
                var keyboarTask = new RecordedUiTask(EnumUiTaskName.KeyboardInput, strBase64, bCapsLock, bScrollLock, bNumLock);
                MainWindow.AddRecordedUi(keyboarTask);
            }

            strBase64 = null;
        }