From 30598d0e8710f687d4f9b5ce545321543b8139c4 Mon Sep 17 00:00:00 2001 From: Ryan Luu Date: Wed, 15 Oct 2025 13:00:06 -0700 Subject: [PATCH 01/44] Add DevWinUI --- FluentAutoClicker/FluentAutoClicker.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/FluentAutoClicker/FluentAutoClicker.csproj b/FluentAutoClicker/FluentAutoClicker.csproj index c57ef56a..5456d789 100644 --- a/FluentAutoClicker/FluentAutoClicker.csproj +++ b/FluentAutoClicker/FluentAutoClicker.csproj @@ -36,6 +36,7 @@ + all runtime; build; native; contentfiles; analyzers; buildtransitive From 31719ccfa9bc11318260cbcef7257a235e141ac4 Mon Sep 17 00:00:00 2001 From: Ryan Luu Date: Wed, 15 Oct 2025 13:06:14 -0700 Subject: [PATCH 02/44] Remove preset hotkey logic --- FluentAutoClicker/MainPage.xaml.cs | 41 ------------------------------ 1 file changed, 41 deletions(-) diff --git a/FluentAutoClicker/MainPage.xaml.cs b/FluentAutoClicker/MainPage.xaml.cs index 93aa81bd..868d6a53 100644 --- a/FluentAutoClicker/MainPage.xaml.cs +++ b/FluentAutoClicker/MainPage.xaml.cs @@ -50,11 +50,6 @@ public MainPage() ToolTipService.SetToolTip(ToggleButtonStart, "ToggleButtonStartTooltipStart".GetLocalized()); } - /// - /// Gets or sets a value indicating whether the hotkey is registered. - /// - private bool IsHotKeyRegistered { get; set; } - /// /// Handles the Loaded event of the MainPage control. /// @@ -64,42 +59,6 @@ private async void MainPage_Loaded(object sender, RoutedEventArgs e) { // Set badge notification SetNotificationBadge(BadgeNotificationGlyph.Paused); - - // Prevent registering multiple hotkeys - if (IsHotKeyRegistered) - { - return; - } - - // Get window handle - MainWindow window = App.MainWindow; - HWND hWnd = new(WindowNative.GetWindowHandle(window)); - - // Set up window message monitor - WindowMessageMonitor monitor = new(window); - monitor.WindowMessageReceived += OnWindowMessageReceived; - - // Register hotkey - bool success = PInvoke.RegisterHotKey(hWnd, 0x0000, HOT_KEY_MODIFIERS.MOD_NOREPEAT, 0x75); // F6 - if (success) - { - IsHotKeyRegistered = true; - } - else - { - ContentDialog dialog = new() - { - // XamlRoot must be set in the case of a ContentDialog running in a Desktop app - XamlRoot = XamlRoot, - Style = Application.Current.Resources["DefaultContentDialogStyle"] as Style, - Title = "Failed to register hotkey", - Content = "Please modify the hotkey setting.", - CloseButtonText = "OK", - DefaultButton = ContentDialogButton.Primary - }; - - _ = await dialog.ShowAsync(); - } } /// From b0ea013b5453d691efe077750fa29d28636eda83 Mon Sep 17 00:00:00 2001 From: Ryan Luu Date: Wed, 15 Oct 2025 13:12:03 -0700 Subject: [PATCH 03/44] Use DevWinUI.Controls IsEnabledTextBlock --- .../IsEnabledTextBlock/IsEnabledTextBlock.cs | 89 ------------------- .../IsEnabledTextBlock.xaml | 35 -------- FluentAutoClicker/MainPage.xaml | 5 +- FluentAutoClicker/Themes/Generic.xaml | 6 -- 4 files changed, 3 insertions(+), 132 deletions(-) delete mode 100644 FluentAutoClicker/Controls/IsEnabledTextBlock/IsEnabledTextBlock.cs delete mode 100644 FluentAutoClicker/Controls/IsEnabledTextBlock/IsEnabledTextBlock.xaml delete mode 100644 FluentAutoClicker/Themes/Generic.xaml diff --git a/FluentAutoClicker/Controls/IsEnabledTextBlock/IsEnabledTextBlock.cs b/FluentAutoClicker/Controls/IsEnabledTextBlock/IsEnabledTextBlock.cs deleted file mode 100644 index a7a56ccc..00000000 --- a/FluentAutoClicker/Controls/IsEnabledTextBlock/IsEnabledTextBlock.cs +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (C) 2025 Ryan Luu -// -// This file is part of Fluent Auto Clicker. -// -// Fluent Auto Clicker is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published -// by the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Fluent Auto Clicker is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with Fluent Auto Clicker. If not, see . - -using Microsoft.UI.Xaml; -using Microsoft.UI.Xaml.Controls; -using System.ComponentModel; - -// To learn more about WinUI, the WinUI project structure, -// and more about our project templates, see: http://aka.ms/winui-project-info. - -namespace FluentAutoClicker.Controls; - -/// -/// A custom control that displays text and changes its visual state based on its enabled state. -/// -[TemplateVisualState(Name = "Normal", GroupName = "CommonStates")] -[TemplateVisualState(Name = "Disabled", GroupName = "CommonStates")] -public partial class IsEnabledTextBlock : Control -{ - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty TextProperty = DependencyProperty.Register( - "Text", - typeof(string), - typeof(IsEnabledTextBlock), - null); - - /// - /// Initializes a new instance of the class. - /// - public IsEnabledTextBlock() - { - DefaultStyleKey = typeof(IsEnabledTextBlock); - } - - /// - /// Gets or sets the text content of the control. - /// - [Localizable(true)] - public string Text - { - get => (string)GetValue(TextProperty); - set => SetValue(TextProperty, value); - } - - /// - /// Applies the control template and sets up the initial visual state. - /// - protected override void OnApplyTemplate() - { - IsEnabledChanged -= IsEnabledTextBlock_IsEnabledChanged; - SetEnabledState(); - IsEnabledChanged += IsEnabledTextBlock_IsEnabledChanged; - base.OnApplyTemplate(); - } - - /// - /// Handles the IsEnabledChanged event and updates the visual state. - /// - /// The source of the event. - /// The event data. - private void IsEnabledTextBlock_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e) - { - SetEnabledState(); - } - - /// - /// Sets the visual state of the control based on its enabled state. - /// - private void SetEnabledState() - { - _ = VisualStateManager.GoToState(this, IsEnabled ? "Normal" : "Disabled", true); - } -} \ No newline at end of file diff --git a/FluentAutoClicker/Controls/IsEnabledTextBlock/IsEnabledTextBlock.xaml b/FluentAutoClicker/Controls/IsEnabledTextBlock/IsEnabledTextBlock.xaml deleted file mode 100644 index ec41958d..00000000 --- a/FluentAutoClicker/Controls/IsEnabledTextBlock/IsEnabledTextBlock.xaml +++ /dev/null @@ -1,35 +0,0 @@ - - - - \ No newline at end of file diff --git a/FluentAutoClicker/MainPage.xaml b/FluentAutoClicker/MainPage.xaml index 3499ce1c..638b9b78 100644 --- a/FluentAutoClicker/MainPage.xaml +++ b/FluentAutoClicker/MainPage.xaml @@ -7,6 +7,7 @@ xmlns:animatedvisuals="using:Microsoft.UI.Xaml.Controls.AnimatedVisuals" xmlns:controls="using:FluentAutoClicker.Controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:dev="using:DevWinUI" xmlns:helpers="using:FluentAutoClicker.Helpers" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:ui="using:CommunityToolkit.WinUI" @@ -40,7 +41,7 @@ - + @@ -103,7 +104,7 @@ Grid.Row="2" Grid.Column="0" Spacing="{StaticResource StackPanelSpacing}"> - +