diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml
index d1d9a88..3338cb8 100644
--- a/.github/workflows/dotnet-core.yml
+++ b/.github/workflows/dotnet-core.yml
@@ -1,23 +1,23 @@
-name: .NET Core 3.1 build
-
-on:
- push:
- branches: [ main ]
- pull_request:
- branches: [ main ]
-
-jobs:
- build:
-
- runs-on: ubuntu-latest
-
- steps:
- - uses: actions/checkout@v2
- - name: Setup .NET Core
- uses: actions/setup-dotnet@v1
- with:
- dotnet-version: 3.1.301
- - name: Install dependencies
- run: dotnet restore
- - name: Build
- run: dotnet build --configuration Release --no-restore
\ No newline at end of file
+name: .NET 5.0
+
+on:
+ push:
+ branches: [ main ]
+ pull_request:
+ branches: [ main ]
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: 5.0.x
+ - name: Restore dependencies
+ run: dotnet restore
+ - name: Build
+ run: dotnet build --no-restore
\ No newline at end of file
diff --git a/src/AutoClicker.cs b/src/AutoClicker.cs
index 99deb6f..2dc1cb8 100644
--- a/src/AutoClicker.cs
+++ b/src/AutoClicker.cs
@@ -17,8 +17,8 @@ namespace VirtualAutoClicker
public class AutoClicker
{
[DllImport("user32.dll", CharSet = CharSet.Auto)]
- private static extern IntPtr SendMessage(IntPtr hWnd, uint message, IntPtr wParam, IntPtr lParam);
-
+ private static extern int SendMessage(IntPtr hWnd, uint message, int wParam, int lParam);
+
///
/// Name of instance
///
@@ -124,15 +124,6 @@ public void Resume()
StartClicker();
}
- ///
- /// Creates parameters which will be sent to simulate coordinates to the SendMessage message.
- /// The coordinate is relative to the upper-left corner of the client area.
- ///
- private static IntPtr CreateLParam(int loWord, int hiWord)
- {
- return (IntPtr)((hiWord << 16) | (loWord & 0xffff));
- }
-
///
/// If all neccsary AutoClicker properties are set, send click message to the set process
///
@@ -143,18 +134,20 @@ private void Click()
return;
}
+ var lParam = (Coordinates.Y << 16) + Coordinates.X;
+
SendMessage(
CurrentProcess.MainWindowHandle,
Buttons.WmLbuttondown,
- new IntPtr(Buttons.MkLbutton),
- CreateLParam(Coordinates.X, Coordinates.Y)
+ 0,
+ lParam
);
-
+
SendMessage(
CurrentProcess.MainWindowHandle,
Buttons.WmLbuttonup,
- new IntPtr(Buttons.MkLbutton),
- CreateLParam(Coordinates.X, Coordinates.Y)
+ 0,
+ lParam
);
}
}
diff --git a/src/Commands/Pause.cs b/src/Commands/Pause.cs
index 86728c6..16ce468 100644
--- a/src/Commands/Pause.cs
+++ b/src/Commands/Pause.cs
@@ -14,6 +14,8 @@ public void Execute(string[] arguments)
var acWorker = VacEnvironment.GetAcWorker();
acWorker?.GetAutoclicker(acName)?.Pause();
+
+ ConsoleHelper.WriteMessage($"autoclicker {acName} paused!");
}
}
}
\ No newline at end of file
diff --git a/src/Commands/Picnic.cs b/src/Commands/Picnic.cs
index 232e521..21489dd 100644
--- a/src/Commands/Picnic.cs
+++ b/src/Commands/Picnic.cs
@@ -7,7 +7,7 @@ public void Execute(string[] arguments)
var acWorker = VacEnvironment.GetAcWorker();
acWorker?.Picnic();
- ConsoleHelper.WriteMessage("Autoclickers stopped!");
+ ConsoleHelper.WriteMessage("All autoclickers stopped!");
}
}
}
\ No newline at end of file
diff --git a/src/Commands/Resume.cs b/src/Commands/Resume.cs
index 5d95ce8..9aa2a70 100644
--- a/src/Commands/Resume.cs
+++ b/src/Commands/Resume.cs
@@ -14,6 +14,8 @@ public void Execute(string[] arguments)
var acWorker = VacEnvironment.GetAcWorker();
acWorker?.GetAutoclicker(acName)?.Resume();
+
+ ConsoleHelper.WriteMessage($"autoclicker {acName} resumed!");
}
}
}
\ No newline at end of file
diff --git a/src/Commands/StartAutoClicker.cs b/src/Commands/StartAutoClicker.cs
index bcd1dab..bf2a8c6 100644
--- a/src/Commands/StartAutoClicker.cs
+++ b/src/Commands/StartAutoClicker.cs
@@ -1,6 +1,4 @@
using System;
-using System.Text.RegularExpressions;
-
using VirtualAutoClicker.Models;
namespace VirtualAutoClicker.Commands
@@ -22,30 +20,34 @@ public void Execute(string[] arguments)
}
var processName = arguments[0];
-
- // If the process name is put between double quotation marks
- if (arguments[0].StartsWith('"') && arguments[0].EndsWith('"'))
+
+ var xConversion = int.TryParse(arguments[1].Split(',')[0], out var x);
+ var yConversion = int.TryParse(arguments[1].Split(',')[1], out var y);
+ if (!xConversion || !yConversion)
{
- var pattern = new Regex("\"(.*?)\"");
- var matches = pattern.Matches(processName);
- if (matches.Count > 0)
- {
- processName = matches[0].Groups[1].Value.Replace("\"", "");
- }
+ ConsoleHelper.WriteWarning("Command usage: 'startautoclicker \"P\" X,Y I N' please refer to the readme.md file for further assistance.");
+ return;
}
-
+
var coordinates = new Coordinates
{
- X = int.Parse(arguments[1].Split(',')[0]),
- Y = int.Parse(arguments[1].Split(',')[1]),
+ X = x,
+ Y = y,
};
+ var intervalConversion = int.TryParse(arguments[2], out var interval);
+ if (!intervalConversion)
+ {
+ ConsoleHelper.WriteWarning("Command usage: 'startautoclicker \"P\" X,Y I N' please refer to the readme.md file for further assistance.");
+ return;
+ }
+
// Instantiate the new autoclicker
Start(
proposedAcName,
processName,
coordinates,
- int.Parse(arguments[2])
+ interval
);
}
diff --git a/src/ConsoleHelper.cs b/src/ConsoleHelper.cs
index 986c469..d393ef6 100644
--- a/src/ConsoleHelper.cs
+++ b/src/ConsoleHelper.cs
@@ -1,4 +1,7 @@
using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
namespace VirtualAutoClicker
{
@@ -43,5 +46,51 @@ public static void WriteError(Exception e)
Console.WriteLine(e);
Console.ForegroundColor = ConsoleColor.White;
}
+
+ public static void WriteStartingMessage()
+ {
+ Console.ForegroundColor = ConsoleColor.White;
+ Console.WriteLine("- - - - - - - - - - - - - - - - - -");
+ Console.WriteLine($"virtual-auto-clicker - Your idle success [version {VacEnvironment.VersionNumber}]");
+ Console.WriteLine("by @versaceLORD - https://github.com/versaceLORD/virtual-auto-clicker");
+ Console.WriteLine("- - - - - - - - - - - - - - - - - -\n\r");
+ }
+
+ public static string[] GetInputArguments(List arguments)
+ {
+ var processName = new StringBuilder();
+
+ if (arguments.Count(arg => arg.Contains("\"", StringComparison.InvariantCultureIgnoreCase)) != 2)
+ {
+ return arguments.ToArray();
+ }
+
+ var doubleQuoteIndex = arguments.FindIndex(arg => arg.StartsWith('"'));
+ var endingIndex = 0;
+ for (var i = 0; i < arguments.Count; i++)
+ {
+ if (arguments[i].EndsWith('"'))
+ {
+ endingIndex = i;
+ }
+ }
+
+ if (endingIndex == 0)
+ {
+ return arguments.ToArray();
+ }
+
+ for (var i = doubleQuoteIndex; i <= endingIndex; i++)
+ {
+ processName.Append($"{arguments[i]} ");
+ }
+
+ arguments.RemoveRange(doubleQuoteIndex, endingIndex + 1);
+ arguments = arguments
+ .Prepend(processName.ToString().Remove(processName.Length - 1, 1))
+ .ToList();
+
+ return arguments.ToArray();
+ }
}
}
diff --git a/src/Constants/Buttons.cs b/src/Constants/Buttons.cs
index a35c60f..fb7690d 100644
--- a/src/Constants/Buttons.cs
+++ b/src/Constants/Buttons.cs
@@ -2,8 +2,17 @@
{
public static class Buttons
{
+ ///
+ /// Left mouse button down
+ ///
public const uint WmLbuttondown = 0x201;
+ ///
+ /// Left mouse button up
+ ///
public const uint WmLbuttonup = 0x202;
+ ///
+ /// Left mouse button
+ ///
public const uint MkLbutton = 0x0001;
}
}
\ No newline at end of file
diff --git a/src/Enums/Button.cs b/src/Enums/Button.cs
deleted file mode 100644
index 2928af9..0000000
--- a/src/Enums/Button.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace VirtualAutoClicker.Enums
-{
- public enum Button : uint
- {
- WM_LButtonDown = 0x201,
- WM_LButtonUp = 0x202,
- MK_LButton = 0x0001
- }
-}
diff --git a/src/Program.cs b/src/Program.cs
index b060bf5..e17d2f1 100644
--- a/src/Program.cs
+++ b/src/Program.cs
@@ -7,14 +7,15 @@ internal static class Program
{
private static void Main()
{
- ConsoleHelper.WriteMessage("Virtual Autoclicker Console is starting!");
+ Console.Title = $"Virtual Autoclicker [{VacEnvironment.VersionNumber}]";
+
+ ConsoleHelper.WriteStartingMessage();
VacEnvironment.Initialize();
StartClosingHandlers();
- Console.Title = "Virtual Autoclicker";
- ConsoleHelper.WriteMessage("Virtual Autoclicker Console has started!\n\r");
+ ConsoleHelper.WriteMessage("Virtual Autoclicker is ready for use - press the enter key to input a command!\n\r");
while (VacEnvironment.Active)
{
@@ -30,15 +31,18 @@ private static void Main()
{
continue;
}
-
- var command = VacEnvironment.GetCommand(input.Split(' ')[0]);
+
+ var inputCommand = input.Split(' ')[0];
+ var arguments = ConsoleHelper.GetInputArguments(input.Split(' ').Skip(1).ToList());
+
+ var command = VacEnvironment.GetCommand(inputCommand);
if (command is null)
{
- ConsoleHelper.WriteWarning($"No command found named '{command}'");
+ ConsoleHelper.WriteWarning($"No command found named '{inputCommand}'");
continue;
}
- command.Execute(input.Split(' ').Skip(1).ToArray());
+ command.Execute(arguments);
}
}
diff --git a/src/Properties/PublishProfiles/Selfcontained windows x64.pubxml b/src/Properties/PublishProfiles/Selfcontained windows x64.pubxml
index d61bf9a..a95e01f 100644
--- a/src/Properties/PublishProfiles/Selfcontained windows x64.pubxml
+++ b/src/Properties/PublishProfiles/Selfcontained windows x64.pubxml
@@ -1,18 +1,18 @@
-
-
-
-
- Release
- Any CPU
- bin\Release\netcoreapp3.1\publish\
- FileSystem
- netcoreapp3.1
- win-x64
- true
- False
- False
- False
-
+
+
+
+
+ Release
+ Any CPU
+ bin\Release\netcoreapp3.1\publish\
+ FileSystem
+ net5.0
+ win-x64
+ true
+ False
+ False
+ False
+
\ No newline at end of file
diff --git a/src/Properties/PublishProfiles/Selfcontained windows x86.pubxml b/src/Properties/PublishProfiles/Selfcontained windows x86.pubxml
index 48698e9..66a8ae0 100644
--- a/src/Properties/PublishProfiles/Selfcontained windows x86.pubxml
+++ b/src/Properties/PublishProfiles/Selfcontained windows x86.pubxml
@@ -1,18 +1,18 @@
-
-
-
-
- Release
- Any CPU
- bin\Release\netcoreapp3.1\publish\
- FileSystem
- netcoreapp3.1
- win-x86
- true
- False
- False
- False
-
+
+
+
+
+ Release
+ Any CPU
+ bin\Release\netcoreapp3.1\publish\
+ FileSystem
+ net5.0
+ win-x86
+ true
+ False
+ False
+ False
+
\ No newline at end of file
diff --git a/src/VacEnvironment.cs b/src/VacEnvironment.cs
index c94e928..f25e7b9 100644
--- a/src/VacEnvironment.cs
+++ b/src/VacEnvironment.cs
@@ -12,6 +12,8 @@ namespace VirtualAutoClicker
///
public static class VacEnvironment
{
+ public const string VersionNumber = "1.1.2";
+
private static AutoClickerWorker? AutoClickerWorker;
public static bool Active { get; private set; }
diff --git a/src/VirtualAutoClicker.csproj b/src/VirtualAutoClicker.csproj
index 3ea0be7..51b4864 100644
--- a/src/VirtualAutoClicker.csproj
+++ b/src/VirtualAutoClicker.csproj
@@ -2,7 +2,7 @@
Exe
- netcoreapp3.1
+ net5.0
VirtualAutoClicker
enable
VirtualAutoClicker