Skip to content

Commit e109b7d

Browse files
Added wait command, fixed syntax
I fixed the syntax of previous commit, I had the {'s on a new line which is wrong. I added the wait action The parameter is a number in milliseconds for the time the program will wait
1 parent 0d757e0 commit e109b7d

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

AssistantComputerControl/Actions.cs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -952,44 +952,43 @@ public void MouseLeftClick(string parameter) {
952952

953953
public const int MOUSEEVENTF_RIGHTDOWN = 0x08;
954954
public const int MOUSEEVENTF_RIGHTUP = 0x10;
955-
public void MouseRightClick(string parameter)
956-
{
955+
public void MouseRightClick(string parameter) {
957956
// Try to get amount of times to click
958-
if (Int32.TryParse(parameter, out int repeatAmount))
959-
{
960-
for (int count = 0; count < repeatAmount; count++)
961-
{
957+
if (Int32.TryParse(parameter, out int repeatAmount)) {
958+
for (int count = 0; count < repeatAmount; count++) {
962959
mouse_event(MOUSEEVENTF_RIGHTDOWN, Cursor.Position.X, Cursor.Position.Y, 0, 0);
963960
mouse_event(MOUSEEVENTF_RIGHTUP, Cursor.Position.X, Cursor.Position.Y, 0, 0);
964961
successMessage = "Simulated pressing the Right mouse button " + repeatAmount + " times";
965962
}
966-
}
967-
else
968-
{
963+
} else {
969964
Error("Repeat amount is not a munber");
970965
}
971966
}
972967

973968
public const int MOUSEEVENTF_MIDDLEDOWN = 0x20;
974969
public const int MOUSEEVENTF_MIDDLEUP = 0x40;
975-
public void MouseMiddleClick(string parameter)
976-
{
970+
public void MouseMiddleClick(string parameter) {
977971
// Try to get amount of times to click
978-
if (Int32.TryParse(parameter, out int repeatAmount))
979-
{
980-
for (int count = 0; count < repeatAmount; count++)
981-
{
972+
if (Int32.TryParse(parameter, out int repeatAmount)) {
973+
for (int count = 0; count < repeatAmount; count++) {
982974
mouse_event(MOUSEEVENTF_MIDDLEDOWN, Cursor.Position.X, Cursor.Position.Y, 0, 0);
983975
mouse_event(MOUSEEVENTF_MIDDLEUP, Cursor.Position.X, Cursor.Position.Y, 0, 0);
984976
successMessage = "Simulated pressing the Middle mouse button " + repeatAmount + " times";
985977
}
986-
}
987-
else
988-
{
978+
} else {
989979
Error("Repeat amount is not a munber");
990980
}
991981
}
992982

983+
public void Wait(string parameter) {
984+
if (Int32.TryParse(parameter, out int time)) {
985+
Thread.Sleep(time);
986+
successMessage = "Waited " + time + " miliseconds";
987+
} else {
988+
Error("Time Parameter is not a number");
989+
}
990+
}
991+
993992
/* End of actions */
994993
}
995994
}

AssistantComputerControl/actionChecker.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -537,15 +537,17 @@ public static Actions ExecuteAction(string action, string line, string parameter
537537
}
538538
break;
539539
case "mouse_middle_click":
540-
if (String.IsNullOrEmpty(parameter))
541-
{
540+
if (String.IsNullOrEmpty(parameter)) {
542541
actionExecution.MouseMiddleClick("1");
543-
}
544-
else
545-
{
542+
} else {
546543
actionExecution.MouseMiddleClick(parameter);
547544
}
548545
break;
546+
case "wait":
547+
if (RequireParameter(parameter)) {
548+
actionExecution.Wait(parameter);
549+
}
550+
break;
549551
default:
550552
//Unknown action
551553
actionExecution.errorMessage = "Unknown action \"" + action + "\"";

0 commit comments

Comments
 (0)