If you do want to give it a go, here's how the plugin I slapped together years ago to do pretty much the same thing is set up:
private static dynamic VA;
public static void VA_Init1(dynamic vaProxy)
{
VA = vaProxy;
VA.ProfileChanged += new Action<Guid?, Guid?, string, string>(ProfileChanged);
ProfileChanged(null, null, "", "");//Profile changing/changed events don't run when VoiceAttack starts, so this makes sure commands run for the initial profiles's included profiles
}
As mentioned, you'd want to call the method explicitly for the initially loaded profile, which doesn't cause ProfileChanged to be triggered.
public static void VA_Invoke1(dynamic vaProxy)
{
VA.WriteToLog("The VoiceAttack Included Profile Initialization plugin does not need to be invoked, it works automatically when you switch profiles", "red");
}
This isn't necessary for the plugin to function, but I included it at the time just in case I were to release the plugin at some point.
public static void ProfileChanged(Guid? FromInternalID, Guid? ToInternalID, string FromName, string ToName)
{
foreach (string profileName in VA.ProfileNames())//There is no method for getting only loaded profiles, so all profiles in the database are checked; Those that aren't included into the active profile would not have their initialization command available, so those will not be executed needlessly
{
string initCommandName = profileName.Replace("[", "").Replace("]", "") + " Initialization";
if (VA.Command.Exists(initCommandName))
{
if (profileName != VA.Profile.Name())//Don't execute the initialization command for the active profile
{
VA.Command.Execute(initCommandName, true);//Execute and wait for command to complete
}
}
}
}
Instead of setting up the plugin so it only works in a very specific scenario, I designed it so no modification to profiles should be necessary after the initial creation of their initialization command.
So this plugin looks for a command with the name of the profile, followed by " Initialization", E.G. "My Profile Initialization", and executes it for any included and global profiles.
Requiring the profile name as part of the command name should ensure that all commands are uniquely named, with a name that's unlikely to be used unintentionally (I.E. the command is intended to be executed when the profile isn't the active profile), and so multiple profiles don't use the same command name (as only one command with the same name can exist).
I will note that I don't use version numbers in the names of my profiles. If your profiles do, you would of course need to rename the command to match.
Removing the brackets is necessary in case they're part of the profile name, as they will automatically be removed by VoiceAttack when they're used in a command name (as they're part of the dynamic command sections syntax).
All other plugin methods are either empty, or return basic properties like the name, description, or GUID (which should be unique; never reuse the GUID from the example project. You can use the "{GUID}" token to generate one if needed)