Skip to content

Commit

Permalink
🐛 fixed Action Mods bug
Browse files Browse the repository at this point in the history
Simply didn't work for most cases...
  • Loading branch information
AlbertMN committed Jan 17, 2022
1 parent c5444e8 commit 0a78bf8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions AssistantComputerControl/ActionMods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ public static Tuple<bool, string, bool> ExecuteModAction(string name, string par
Console.WriteLine("Requires parameter? " + requiresParameter);
Console.WriteLine("Has parameter? " + !String.IsNullOrEmpty(parameter));

string[] secondaryParameters = ActionChecker.GetSecondaryParam(parameter);
string[] secondaryParameters = ActionChecker.GetSecondaryParam(parameter ?? "");
if (requiresSecondaryParameter ? secondaryParameters.Length > 1 : true) { //Also returns the first parameter
if (File.Exists(scriptFileLocation)) {
string accArg = requiresParameter && requiresSecondaryParameter ? JsonConvert.SerializeObject(ActionChecker.GetSecondaryParam(parameter)) : (requiresParameter ? parameter : "");
string secondParameter = secondaryParameters.Length == 1 ? "" : secondaryParameters[1];

try {
ProcessStartInfo p = new ProcessStartInfo {
Expand All @@ -214,7 +214,7 @@ public static Tuple<bool, string, bool> ExecuteModAction(string name, string par
if (theExtension == ".ps1") {
//Is powershell - open it correctly
p.FileName = "powershell.exe";
p.Arguments = String.Format("-WindowStyle Hidden -file \"{0}\" \"{1}\"", scriptFileLocation, accArg);
p.Arguments = String.Format("-WindowStyle Hidden -file \"{0}\" \"{1}\" \"{2}\"", scriptFileLocation, parameter, secondParameter);
} else if (theExtension == ".py") {
//Python - open it correctly
string minPythonVersion = (jsonTest["options"]["min_python_version"] ?? ""),
Expand All @@ -223,7 +223,7 @@ public static Tuple<bool, string, bool> ExecuteModAction(string name, string par

if (pythonPath != "") {
p.FileName = GetPythonPath();
p.Arguments = String.Format("{0} \"{1}\"", scriptFileLocation, accArg);
p.Arguments = String.Format("{0} \"{1}\" \"{2}\"", scriptFileLocation, parameter, secondParameter);
} else {
//No python version (or one with the min-max requirements) not found.
string pythonErr;
Expand Down Expand Up @@ -251,11 +251,11 @@ public static Tuple<bool, string, bool> ExecuteModAction(string name, string par
} else if (theExtension == ".bat" || theExtension == ".cmd" || theExtension == ".btm") {
//Is batch - open it correctly (https://en.wikipedia.org/wiki/Batch_file#Filename_extensions)
p.FileName = "cmd.exe";
p.Arguments = String.Format("/c {0} \"{1}\"", scriptFileLocation, accArg);
p.Arguments = String.Format("/c {0} \"{1}\" \"{2}\"", scriptFileLocation, parameter, secondParameter);
} else {
//"Other" filetype. Simply open file.
p.FileName = scriptFileLocation;
p.Arguments = accArg;
p.Arguments = String.Format("\"{0}\" \"{1}\"", parameter, secondParameter);
}

Process theP = Process.Start(p);
Expand Down

0 comments on commit 0a78bf8

Please sign in to comment.