diff --git a/FluentAutoClicker/App.xaml.cs b/FluentAutoClicker/App.xaml.cs index ab9d74e..76a7709 100644 --- a/FluentAutoClicker/App.xaml.cs +++ b/FluentAutoClicker/App.xaml.cs @@ -27,6 +27,8 @@ namespace FluentAutoClicker; /// public partial class App : Application { + public static Window Window { get; private set; } = null!; + /// /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). @@ -45,6 +47,4 @@ protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs ar Window = new MainWindow(); Window.Activate(); } - - public static Window Window { get; private set; } } \ No newline at end of file diff --git a/FluentAutoClicker/FluentAutoClicker.csproj b/FluentAutoClicker/FluentAutoClicker.csproj index ed24f5d..0e586ee 100644 --- a/FluentAutoClicker/FluentAutoClicker.csproj +++ b/FluentAutoClicker/FluentAutoClicker.csproj @@ -10,6 +10,7 @@ win-x86;win-x64;win-arm64 win-$(Platform).pubxml enable + enable true true DISABLE_XAML_GENERATED_MAIN diff --git a/FluentAutoClicker/Helpers/AutoClicker.cs b/FluentAutoClicker/Helpers/AutoClicker.cs index 3da99d2..0cc2be2 100644 --- a/FluentAutoClicker/Helpers/AutoClicker.cs +++ b/FluentAutoClicker/Helpers/AutoClicker.cs @@ -27,7 +27,7 @@ public static class AutoClicker [DllImport("user32.dll", SetLastError = true)] private static extern uint SendInput(uint nInputs, Input[] pInputs, int cbSize); - private static Thread _autoClickerThread; + private static Thread? _autoClickerThread; private static bool _isAutoClickerRunning; /// diff --git a/FluentAutoClicker/Helpers/WindowMessageHook.cs b/FluentAutoClicker/Helpers/WindowMessageHook.cs index ddc6ca4..5c8b075 100644 --- a/FluentAutoClicker/Helpers/WindowMessageHook.cs +++ b/FluentAutoClicker/Helpers/WindowMessageHook.cs @@ -29,7 +29,7 @@ public class WindowMessageHook : IEquatable, IDisposable private static readonly ConcurrentDictionary Hooks = new(); private static readonly Subclassproc Proc = SubclassProc; - public event EventHandler Message; + public event EventHandler? Message; private nint _hWnd; public WindowMessageHook(Window window) : this(GetHandle(window)) { } @@ -97,7 +97,7 @@ private static nint GetHandle(Window window) private static nint SubclassProc(nint hWnd, uint uMsg, nint wParam, nint lParam, nint uIdSubclass, uint dwRefData) { - if (Hooks.TryGetValue(hWnd, out WindowMessageHook hook)) + if (Hooks.TryGetValue(hWnd, out WindowMessageHook? hook)) { MessageEventArgs e = new(hWnd, uMsg, wParam, lParam); hook.OnMessage(hook, e); @@ -114,17 +114,17 @@ public override int GetHashCode() return _hWnd.GetHashCode(); } - public override string ToString() + public override string? ToString() { return _hWnd.ToString(); } - public override bool Equals(object obj) + public override bool Equals(object? obj) { return Equals(obj as WindowMessageHook); } - public virtual bool Equals(WindowMessageHook other) + public virtual bool Equals(WindowMessageHook? other) { return other != null && _hWnd.Equals(other._hWnd); } @@ -145,4 +145,4 @@ public MessageEventArgs(nint hWnd, uint uMsg, nint wParam, nint lParam) public nint WParam { get; } public nint LParam { get; } public virtual nint? Result { get; set; } -} \ No newline at end of file +} diff --git a/FluentAutoClicker/Program.cs b/FluentAutoClicker/Program.cs index 2d9bf17..d535db8 100644 --- a/FluentAutoClicker/Program.cs +++ b/FluentAutoClicker/Program.cs @@ -53,7 +53,7 @@ private static bool DecideRedirection() bool isRedirect = false; AppActivationArguments args = AppInstance.GetCurrent().GetActivatedEventArgs(); ExtendedActivationKind kind = args.Kind; - AppInstance keyInstance = AppInstance.FindOrRegisterForKey("MySingleInstanceApp"); + AppInstance keyInstance = AppInstance.FindOrRegisterForKey("FluentAutoClickerApp"); if (keyInstance.IsCurrent) { @@ -71,7 +71,7 @@ private static bool DecideRedirection() [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] private static extern IntPtr CreateEvent( IntPtr lpEventAttributes, bool bManualReset, - bool bInitialState, string lpName); + bool bInitialState, string? lpName); [DllImport("kernel32.dll")] private static extern bool SetEvent(IntPtr hEvent); @@ -109,7 +109,7 @@ public static void RedirectActivationTo(AppActivationArguments args, _ = SetForegroundWindow(process.MainWindowHandle); } - private static void OnActivated(object sender, AppActivationArguments args) + private static void OnActivated(object? sender, AppActivationArguments args) { _ = args.Kind; }