Skip to content

Commit 1a3f4de

Browse files
committed
Added "display_switch" action + no prefer 32 bit
- test to see if disabling the "Prefer 32 bit" setting helps issue #109 - added "display_switch" action so a "batch hack" isn't required
1 parent 2556077 commit 1a3f4de

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

AssistantComputerControl/Actions.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ public void Open(string parameter) {
420420

421421
if (fileLocation != "") {
422422
MainProgram.DoDebug(fileLocation);
423+
423424
try {
424425
if (File.Exists(fileLocation) || Directory.Exists(fileLocation) || Uri.IsWellFormedUriString(fileLocation, UriKind.Absolute)) {
425426
if (!MainProgram.testingAction) {
@@ -1168,6 +1169,35 @@ public void IgnoreMe() {
11681169
successMessage = "Ignoring filename";
11691170
}
11701171

1172+
public void DisplayMode(string parameter) {
1173+
string[] supported = { "external", "internal", "extend", "clone", "", null};
1174+
if (supported.Contains(parameter)) {
1175+
var proc = new Process();
1176+
bool hasParameter = false;
1177+
1178+
proc.StartInfo.FileName = @"DisplaySwitch";
1179+
if (parameter != null && parameter.Length > 0) {
1180+
hasParameter = true;
1181+
proc.StartInfo.Arguments = "/" + parameter;
1182+
}
1183+
1184+
try {
1185+
proc.Start();
1186+
1187+
//All good; essage
1188+
if (hasParameter) {
1189+
successMessage = "Switched to " + parameter + " display mode";
1190+
} else {
1191+
successMessage = "Opened DisplaySwitch";
1192+
}
1193+
} catch (Exception e) {
1194+
Error("Failed to switch display, most likely because it targets the wrong directory (64 vs. 32 bit)");
1195+
}
1196+
} else {
1197+
Error("Mode \"" + parameter + "\" not supported");
1198+
}
1199+
}
1200+
11711201
/* End of actions */
11721202
}
11731203
}

AssistantComputerControl/actionChecker.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,9 @@ public static Actions ExecuteAction(string action, string line, string parameter
552552
case "ignoreme":
553553
actionExecution.IgnoreMe();
554554
break;
555+
case "display_switch":
556+
actionExecution.DisplayMode(parameter);
557+
break;
555558
default:
556559
//Unknown action
557560
actionExecution.errorMessage = "Unknown action \"" + action + "\"";

AssistantComputerControl/bin/Debug/AssistantComputerControl.exe.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@
8686
<setting name="StartsUsingRegistry" serializeAs="String">
8787
<value>False</value>
8888
</setting>
89+
<setting name="ActionMessageBox" serializeAs="String">
90+
<value>True</value>
91+
</setting>
8992
</AssistantComputerControl.Properties.Settings>
9093
</userSettings>
9194
<runtime>

0 commit comments

Comments
 (0)