using LoginPI.Engine.ScriptBase; using System; using System.IO; using System.Collections.Generic; using System.Runtime.InteropServices; public class typeRandomSentence : ScriptBase { static readonly string filePath = @"%temp%\loginvsi.txt"; static List list = new List(); static readonly Random rnd = new Random(); private void Execute() { /* -Disclaimer: This workload is provided as-is and might need further configuration and customization to work successfully in each unique environment. For further Professional Services-based customization please consult with the Login VSI Support and Services team. Please refer to the Help Center section "Application Customization" for further self-help information regarding workload crafting and implementation. -Run the workload against the "target" using Script Editor to ensure it will work before uploading it and testing with it -Go through the workload to understand what it's doing. Comment out any unneeded app tests (code blocks) or add on any needed functional testing -This workload will: type a random sentence -Workload version and changelist: --V1.0 | original -Leave Application running compatibility: false */ START(); // Type two random sentences MainWindow.Type(RandomSentence(), cpm: 999); MainWindow.Type(RandomSentence(), cpm: 999); // Type three random sentences in one line of code MainWindow.Type(RandomSentence() + RandomSentence() + RandomSentence(), cpm: 999); Wait(5); } string RandomSentence() { if (list.Count == 0) { ReadTextFile(filePath); } string sentence = ""; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { var index = rnd.Next(list.Count); sentence = list[index]; } return sentence; } void ReadTextFile(string filePath) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { if (!(FileExists(filePath))) { CopyFile(KnownFiles.PlainTextFile, filePath); } using var sr = new StreamReader(Environment.ExpandEnvironmentVariables(filePath)); string line; while ((line = sr.ReadLine()) != null) { string[] split = line.Split(new Char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); foreach (string s in split) { if ((s != "") && (s != ".")) { list.Add(s.Trim() + ".\n"); } } } } } }