Skip to content

Commit f1fef5d

Browse files
committed
Merge branch 'add-openAny' of https://github.com/minhe7735/AssistantComputerControl into add-openAny
2 parents 82a0bdf + 35309cb commit f1fef5d

File tree

3 files changed

+17
-30
lines changed

3 files changed

+17
-30
lines changed

AssistantComputerControl/Actions.cs

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -445,46 +445,34 @@ public void Open(string parameter) {
445445
}
446446
}
447447
}
448-
public void OpenAny(string parameter)
449-
{
448+
public void OpenAny(string parameter) {
450449
string fileLocation = MainProgram.shortcutLocation;
451450
Regex rx = new Regex("^" + parameter + Regex.Escape(".") + ".*", RegexOptions.IgnoreCase);
452-
if (Directory.Exists(fileLocation) || Uri.IsWellFormedUriString(fileLocation, UriKind.Absolute))
453-
{
451+
452+
if (Directory.Exists(fileLocation) || Uri.IsWellFormedUriString(fileLocation, UriKind.Absolute)) {
454453
DirectoryInfo d = new DirectoryInfo(fileLocation);
455454
bool opened = false;
456-
foreach (var dirFile in d.GetFiles())
457-
{
458-
if (!MainProgram.testingAction)
459-
{
455+
foreach (var dirFile in d.GetFiles()) {
456+
if (!MainProgram.testingAction) {
460457
bool result = rx.IsMatch(dirFile.Name);
461-
if (result)
462-
{
458+
if (result) {
463459
Process.Start(dirFile.FullName);
464460
opened = true;
465461
break;
466462
}
467463
}
468464
}
469-
if (!opened)
470-
{
465+
466+
if (!opened) {
471467
Error("File(" + parameter + ") doesn't exist at" + " (" + fileLocation + ")");
472-
}
473-
else
474-
{
475-
if (!MainProgram.testingAction)
476-
{
468+
} else {
469+
if (!MainProgram.testingAction) {
477470
successMessage = "OPEN: opened " + parameter;
478-
}
479-
else
480-
{
471+
} else {
481472
successMessage = "OPEN: simulated opening " + parameter;
482473
}
483474
}
484-
485-
}
486-
else
487-
{
475+
} else {
488476
Error("Directory doesn't exist (" + fileLocation + ")");
489477
}
490478
}

AssistantComputerControl/MainProgram.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,8 @@ public static void TaskSchedulerSetup () {
437437
td.RegistrationInfo.Author = "Albert MN. | AssistantComputerControl";
438438
td.RegistrationInfo.Description = "AssistantComputerControl cleanup - clears the action folder to prevent the same action being executed twice";
439439

440-
td.Actions.Add(new ExecAction("powershell.exe", $"-WindowStyle Hidden -file \"{ps1File}\" \"{Path.Combine(MainProgram.CheckPath(), "*")}\" \"*.{Properties.Settings.Default.ActionFileExtension}\"", null));
441-
440+
td.Actions.Add(new ExecAction("mshta.exe", $"vbscript:Execute(\"CreateObject(\"\"WScript.Shell\"\").Run \"\"powershell -ExecutionPolicy Bypass & '{ps1File}' '{Path.Combine(MainProgram.CheckPath(), "*")}' '*.{Properties.Settings.Default.ActionFileExtension}'\"\", 0:close\")", null));
441+
442442
td.Triggers.Add(new LogonTrigger { UserId = userId, });
443443
ts.RootFolder.RegisterTaskDefinition(@"AssistantComputerControl cleanup", td);
444444
}
@@ -936,4 +936,4 @@ public static bool IsValidPath(string path, bool allowRelativePaths = false) {
936936
return isValid;
937937
}
938938
}
939-
}
939+
}

AssistantComputerControl/actionChecker.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,7 @@ public static Actions ExecuteAction(string action, string line, string parameter
474474
}
475475
break;
476476
case "open_any":
477-
if (RequireParameter(parameter))
478-
{
477+
if (RequireParameter(parameter)) {
479478
actionExecution.OpenAny(parameter);
480479
}
481480
break;
@@ -567,4 +566,4 @@ public static Actions ExecuteAction(string action, string line, string parameter
567566
return actionExecution;
568567
}
569568
}
570-
}
569+
}

0 commit comments

Comments
 (0)