I got a result from trained bot when I ask "Using Libre automate to write script creating several text files in a folder on desktop if not exist please create it, each text will be populated with a poem; second, screenshots of each text file are taken ; third, the text files are renamed; finally, each screenshot is opened in Windows Paint. Use the most updated method from LibreAutomate."
This AI generated code is working good.
[code]// script "Chatbot_Training.cs"
// Add necessary namespaces
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
// Create folder on Desktop
string desktop = folders.Desktop;
string folderPath = pathname.combine(desktop, "PoemFiles");
filesystem.createDirectory(folderPath);
// Sample poems to write to files
var poems = new[] {
new { FileName = "poem1.txt", Content = "Roses are red,\nViolets are blue,\nSugar is sweet,\nAnd so are you!" },
new { FileName = "poem2.txt", Content = "The world is charged\nWith the grandeur of God.\nIt will flame out,\nLike shining from shook foil;" },
new { FileName = "poem3.txt", Content = "I think that I shall never see\nA poem lovely as a tree." }
};
// Create text files with poems
foreach (var poem in poems) {
string filePath = pathname.combine(folderPath, poem.FileName);
File.WriteAllText(filePath, poem.Content);
}
// Take screenshots of text content
foreach (var poem in poems) {
string text = File.ReadAllText(pathname.combine(folderPath, poem.FileName));
using (Bitmap bmp = new Bitmap(800, 600)) {
using (var g = Graphics.FromImage(bmp)) {
g.Clear(Color.White);
using (var font = new Font("Arial", 14)) {
var rect = new RectangleF(10, 10, 780, 580);
g.DrawString(text, font, Brushes.Black, rect);
}
}
string screenshotName = Path.GetFileNameWithoutExtension(poem.FileName) + "_screenshot.png";
string screenshotPath = pathname.combine(folderPath, screenshotName);
bmp.Save(screenshotPath, ImageFormat.Png);
}
}
// Rename text files
foreach (var poem in poems) {
string oldPath = pathname.combine(folderPath, poem.FileName);
string newName = Path.GetFileNameWithoutExtension(poem.FileName) + "_renamed.txt";
string newPath = pathname.combine(folderPath, newName);
File.Move(oldPath, newPath);
}
// Open screenshots in Paint
foreach (var poem in poems) {
string screenshotName = Path.GetFileNameWithoutExtension(poem.FileName) + "_screenshot.png";
string screenshotPath = pathname.combine(folderPath, screenshotName);
run.it("mspaint.exe", screenshotPath);
}
[/code]