Pudge 24 Posted November 20, 2021 Share Posted November 20, 2021 Hi, I am trying to write a code that will create a new profile in the relogger, It looks like this: public void AddNewReloggerProfile(string AccName, string pass, string charname, string key, string wowpath, string profilename, string runtime) { System.Threading.Tasks.Task.Factory.StartNew(() => { try { Logging.Write("1"); var newprofile = new Relogger.Classes.ReloggerProfile(); Logging.Write("2"); //Relogger.Classes.ReloggerProfileSettings. newprofile.Name = AccName + " " + pass + " " + charname; Logging.Write("3"); newprofile.CurrentWowAccount.AccountName = AccName; Logging.Write("4"); newprofile.CurrentWowAccount.BattleNet = AccName; Logging.Write("5"); newprofile.CurrentWowAccount.Password = pass; Logging.Write("6"); newprofile.CurrentWowAccount.Character = charname; Logging.Write("7"); newprofile.Checked = true; Logging.Write("8"); newprofile.Settings.MinimiseWRobotOnStart = true; Logging.Write("9"); newprofile.Settings.RelaunchIfWowOrWRobotCrash = true; Logging.Write("10"); newprofile.Settings.RunTasksLoop = true; Logging.Write("11"); newprofile.Settings.ScheduleResetAtEnd = true; Logging.Write("12"); newprofile.Settings.Tasks.Add(new Relogger.Classes.ReloggerTask { TaskType = Relogger.Classes.TaskType.ChangeWowPath.ToString(), Task = new Relogger.Classes.ChangeWowPathReloggerTask { WowPath = wowpath }, Name = "123" }); Logging.Write("13"); newprofile.Settings.Tasks.Add(new Relogger.Classes.ReloggerTask { TaskType = Relogger.Classes.TaskType.Run.ToString(), Task = new Relogger.Classes.RunReloggerTask { RunTime = runtime, Product = "Quester", Profile = profilename, }, Name = "run" }); Relogger.Classes.ReloggerGeneralSettings.CurrentSetting.Profiles.Add(newprofile); } catch (Exception e) { Logging.WriteError(e.ToString()); } }); } I'm testing through the OnButtonPress () method: public override void OnButtonPress() { AddNewReloggerProfile("124", "124", "124", "124", "124", "124", "124"); base.OnButtonPress(); } } But I am getting the error: 20 ноя 2021 07H35.log.html If you use the code outside the Task.Factory (()) thread, the program simply stops responding. Any help would be welcome, thanks. Link to comment https://wrobot.eu/forums/topic/13692-add-new-relogger-profile-code/ Share on other sites More sharing options...
Droidz 2742 Posted November 21, 2021 Share Posted November 21, 2021 Hey, using System; using System.Threading; using System.Windows.Forms; using Relogger.Classes; using robotManager.Helpful; namespace MyNamespace { public class MyPlugin : Relogger.ReloggerPlugin { public override string Name { get { return "My test plugin"; } } bool IsRunning { get; set; } public override void OnStart() { } public override void OnStop() { } public override void OnButtonPress() { AddNewReloggerProfile("124", "124", "124", "124", "124", "124", "124"); } public void AddNewReloggerProfile(string AccName, string pass, string charname, string key, string wowpath, string profilename, string runtime) { var t = new Thread(o => { try { Logging.Write("1"); var newprofile = new Relogger.Classes.ReloggerProfile(); Logging.Write("2"); //Relogger.Classes.ReloggerProfileSettings. newprofile.Name = AccName + " " + pass + " " + charname; Logging.Write("3"); newprofile.CurrentWowAccount = new ChangeCharacterReloggerTask(); newprofile.CurrentWowAccount.AccountName = AccName; Logging.Write("4"); newprofile.CurrentWowAccount.BattleNet = AccName; Logging.Write("5"); newprofile.CurrentWowAccount.Password = pass; Logging.Write("6"); newprofile.CurrentWowAccount.Character = charname; Logging.Write("7"); newprofile.Checked = true; Logging.Write("8"); newprofile.Settings.MinimiseWRobotOnStart = true; Logging.Write("9"); newprofile.Settings.RelaunchIfWowOrWRobotCrash = true; Logging.Write("10"); newprofile.Settings.RunTasksLoop = true; Logging.Write("11"); newprofile.Settings.ScheduleResetAtEnd = true; Logging.Write("12"); newprofile.Settings.Tasks.Add(new Relogger.Classes.ReloggerTask { TaskType = Relogger.Classes.TaskType.ChangeWowPath.ToString(), Task = new Relogger.Classes.ChangeWowPathReloggerTask { WowPath = wowpath }, Name = "123" }); Logging.Write("13"); newprofile.Settings.Tasks.Add(new Relogger.Classes.ReloggerTask { TaskType = Relogger.Classes.TaskType.Run.ToString(), Task = new Relogger.Classes.RunReloggerTask { RunTime = runtime, Product = "Quester", Profile = profilename, }, Name = "run" }); Relogger.Classes.ReloggerGeneralSettings.CurrentSetting.Profiles.Add(newprofile); } catch (Exception e) { Logging.WriteError(e.ToString()); } }); t.SetApartmentState(ApartmentState.STA); t.Start(); } } } To refresh UI you need to click on profiles list Link to comment https://wrobot.eu/forums/topic/13692-add-new-relogger-profile-code/#findComment-64095 Share on other sites More sharing options...
Pudge 24 Posted November 23, 2021 Author Share Posted November 23, 2021 public void AddNewReloggerProfile(string AccName, string pass, string charname, string server, string Wrobotkey, string wowpath, string profilename, string runtime) { var t = new Thread(o => { try { Logging.Write("1"); var newprofile = new Relogger.Classes.ReloggerProfile(); //Logging.Write("2"); //Relogger.Classes.ReloggerProfileSettings. newprofile.Name = AccName + " " + pass + " " + charname; //newprofile.CurrentTaskIndex // Logging.Write("3"); newprofile.CurrentWowAccount = new Relogger.Classes.ChangeCharacterReloggerTask(); newprofile.CurrentWRobotAccount = new Relogger.Classes.ChangeWRobotLicenseKeyReloggerTask(); newprofile.CurrentWRobotAccount.WRobotKey = Wrobotkey; newprofile.CurrentWowAccount.AccountName = AccName; newprofile.CurrentWowAccount.Server = server; // Logging.Write("4"); newprofile.CurrentWowAccount.BattleNet = AccName; // Logging.Write("5"); newprofile.CurrentWowAccount.Password = pass; //Logging.Write("6"); newprofile.CurrentWowAccount.Character = charname; //Logging.Write("7"); newprofile.Checked = true; // Logging.Write("8"); newprofile.Settings.MinimiseWRobotOnStart = true; // Logging.Write("9"); newprofile.Settings.RelaunchIfWowOrWRobotCrash = true; //Logging.Write("10"); newprofile.Settings.RunTasksLoop = true; // Logging.Write("11"); newprofile.Settings.ScheduleResetAtEnd = true; // Logging.Write("12"); newprofile.Settings.Tasks.Add(new Relogger.Classes.ReloggerTask { TaskType = Relogger.Classes.TaskType.ChangeWowPath.ToString(), Task = new Relogger.Classes.ChangeWowPathReloggerTask { WowPath = wowpath }, Name = "123" }); //Logging.Write("13"); newprofile.Settings.Tasks.Add(new Relogger.Classes.ReloggerTask { TaskType = Relogger.Classes.TaskType.Run.ToString(), Task = new Relogger.Classes.RunReloggerTask { RunTime = runtime, Product = "Quester", Profile = profilename, }, Name = "run" }); Relogger.Classes.ReloggerGeneralSettings.CurrentSetting.Profiles.Add(newprofile); } catch (Exception e) { Logging.WriteError(e.ToString()); } }); t.SetApartmentState(ApartmentState.STA); t.Start(); } Hi, I tested your snippet of code, slightly changing it, the profile is created, but the data such as Password, AccountName, CharacterName and key do not change, also, an error pops up when you click on ChangeWowpath or Run Task. https://youtu.be/7DqBFwXmtgk 23 ноя 2021 20H02.log.html Link to comment https://wrobot.eu/forums/topic/13692-add-new-relogger-profile-code/#findComment-64122 Share on other sites More sharing options...
Droidz 2742 Posted November 25, 2021 Share Posted November 25, 2021 using System; using System.Threading; using System.Windows.Forms; using Relogger.Classes; using robotManager.Helpful; namespace MyNamespace { public class MyPlugin : Relogger.ReloggerPlugin { public override string Name { get { return "My test plugin"; } } bool IsRunning { get; set; } public override void OnStart() { robotManager.Helpful.Logging.Write("OnStart"); } public override void OnStop() { robotManager.Helpful.Logging.Write("OnStop"); } public override void OnButtonPress() { AddNewReloggerProfile("AccName", "realmListName", "pass", "charname", "key", "wowpath", "profilename", "1-10"); robotManager.Helpful.Logging.Write("OnButtonPress"); } public void AddNewReloggerProfile(string AccName, string realmListName, string pass, string charname, string key, string wowpath, string profilename, string runtime) { var t = new Thread(o => { try { var newprofile = new Relogger.Classes.ReloggerProfile(); newprofile.Name = AccName + " " + pass + " " + charname; newprofile.Checked = true; //newprofile.Comment = ""; newprofile.Settings.MinimiseWRobotOnStart = true; newprofile.Settings.RelaunchIfWowOrWRobotCrash = true; newprofile.Settings.RunTasksLoop = true; newprofile.Settings.ScheduleResetAtEnd = true; newprofile.Settings.WowAccount.AccountName = AccName; newprofile.Settings.WowAccount.BattleNet = AccName; newprofile.Settings.WowAccount.Password = pass; newprofile.Settings.WowAccount.Character = charname; newprofile.Settings.WowAccount.Server = realmListName; newprofile.Settings.WRobotAccount.WRobotKey = key; //newprofile.Settings.WowWindow = new Rectangle(); //newprofile.Settings.BotWindow = new Rectangle(); //newprofile.Settings.ScheduleFrom = new DateTime(1, 1, 1, 00, 00, 00); //newprofile.Settings.ScheduleTo = new DateTime(1, 1, 1, 23, 59, 59); newprofile.Settings.Tasks.Add(new Relogger.Classes.ReloggerTask { TaskType = Relogger.Classes.TaskType.ChangeWowPath.ToString(), Task = new Relogger.Classes.ChangeWowPathReloggerTask { WowPath = wowpath }, Name = "123" } ); newprofile.Settings.Tasks.Add(new Relogger.Classes.ReloggerTask { TaskType = Relogger.Classes.TaskType.Run.ToString(), Task = new Relogger.Classes.RunReloggerTask { RunTime = runtime, Product = "Quester", Profile = profilename, }, Name = "run" }); Relogger.Classes.ReloggerGeneralSettings.CurrentSetting.Profiles.Add(newprofile); } catch (Exception e) { Logging.WriteError(e.ToString()); } }); t.SetApartmentState(ApartmentState.STA); t.Start(); } } } You still get error when you try to edit task, but tasks are well configured (you can restart to see value) happiness7 1 Link to comment https://wrobot.eu/forums/topic/13692-add-new-relogger-profile-code/#findComment-64138 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now