From 6dbcebf6400f16eee6fdf71182bdae6cc47753b7 Mon Sep 17 00:00:00 2001 From: Steve Williams Date: Thu, 26 Jan 2023 21:53:18 +0000 Subject: [PATCH] Release 4.16.0. --- 4x/Move Mouse/Actions/ActionBase.cs | 44 ++++++++++++ .../Actions/ActivateApplicationAction.cs | 2 +- 4x/Move Mouse/Actions/ClickMouseAction.cs | 2 +- 4x/Move Mouse/Actions/CommandAction.cs | 2 +- .../Actions/MoveMouseCursorAction.cs | 3 +- .../Actions/PositionMouseCursorAction.cs | 2 +- 4x/Move Mouse/Actions/ScriptAction.cs | 2 +- 4x/Move Mouse/Actions/ScrollMouseAction.cs | 2 +- 4x/Move Mouse/Actions/SleepAction.cs | 2 +- 4x/Move Mouse/Classes/Settings.cs | 15 ++++ 4x/Move Mouse/Properties/AssemblyInfo.cs | 4 +- 4x/Move Mouse/StaticCode.cs | 3 +- .../ViewModels/MouseWindowViewModel.cs | 57 ++++++++++++--- 4x/Move Mouse/Views/MouseWindow.xaml | 4 +- 4x/Move Mouse/Views/MouseWindow.xaml.cs | 24 +++---- 4x/Move Mouse/Views/SettingsWindow.xaml | 69 +++++++++++++++++-- 4x/Move Mouse/Views/SettingsWindow.xaml.cs | 11 ++- 4x/Move Mouse/Wrappers/NativeMethods.cs | 35 +++------- 18 files changed, 213 insertions(+), 70 deletions(-) diff --git a/4x/Move Mouse/Actions/ActionBase.cs b/4x/Move Mouse/Actions/ActionBase.cs index 567c3f1..f1a2f04 100644 --- a/4x/Move Mouse/Actions/ActionBase.cs +++ b/4x/Move Mouse/Actions/ActionBase.cs @@ -17,6 +17,9 @@ public abstract class ActionBase : INotifyPropertyChanged private bool _isEnabled; private bool _repeat; private EventTrigger _trigger; + private IntervalRepeatMode _repeatMode; + private int _intervalThrottle; + private int _intervalExecutionCount; public enum EventTrigger { @@ -25,6 +28,12 @@ public enum EventTrigger Stop } + public enum IntervalRepeatMode + { + Forever, + Throttle + } + public abstract bool IsValid { get; } public Guid Id { get; set; } @@ -74,12 +83,47 @@ public EventTrigger Trigger public IEnumerable EventTriggerValues => Enum.GetValues(typeof(EventTrigger)).Cast(); + public IntervalRepeatMode RepeatMode + { + get => _repeatMode; + set + { + _repeatMode = value; + OnPropertyChanged(); + } + } + + public IEnumerable IntervalRepeatModeValues => Enum.GetValues(typeof(IntervalRepeatMode)).Cast(); + + public int IntervalThrottle + { + get => _intervalThrottle; + set + { + _intervalThrottle = value; + OnPropertyChanged(); + } + } + + [XmlIgnore] + public int IntervalExecutionCount + { + get => _intervalExecutionCount; + set + { + _intervalExecutionCount = value; + OnPropertyChanged(); + } + } + protected ActionBase() { Id = Guid.NewGuid(); _isEnabled = true; _repeat = true; _trigger = EventTrigger.Interval; + _repeatMode = IntervalRepeatMode.Forever; + _intervalThrottle = 1; ExecuteCommand = new RelayCommand(param => Execute(), param => CanExecute()); } diff --git a/4x/Move Mouse/Actions/ActivateApplicationAction.cs b/4x/Move Mouse/Actions/ActivateApplicationAction.cs index e5771c7..2e4bf12 100644 --- a/4x/Move Mouse/Actions/ActivateApplicationAction.cs +++ b/4x/Move Mouse/Actions/ActivateApplicationAction.cs @@ -184,7 +184,7 @@ private void RefreshApplications() public override string ToString() { - return $"Name = {Name} | Mode = {Mode} | Application = {Application} | Trigger = {Trigger} | Repeat = {Repeat}"; + return $"{this.GetType().Name} | Name = {Name} | Mode = {Mode} | Application = {Application} | Trigger = {Trigger} | Repeat = {Repeat} | RepeatMode = {RepeatMode} | IntervalThrottle = {IntervalThrottle} | IntervalExecutionCount = {IntervalExecutionCount}"; } } } \ No newline at end of file diff --git a/4x/Move Mouse/Actions/ClickMouseAction.cs b/4x/Move Mouse/Actions/ClickMouseAction.cs index bce2b8f..e637365 100644 --- a/4x/Move Mouse/Actions/ClickMouseAction.cs +++ b/4x/Move Mouse/Actions/ClickMouseAction.cs @@ -111,7 +111,7 @@ public override void Execute() public override string ToString() { - return $"Name = {Name} | Button = {Button} | Hold = {Hold} | HoldInterval = {HoldInterval} | Trigger = {Trigger} | Repeat = {Repeat}"; + return $"{this.GetType().Name} | Name = {Name} | Button = {Button} | Hold = {Hold} | HoldInterval = {HoldInterval} | Trigger = {Trigger} | Repeat = {Repeat} | RepeatMode = {RepeatMode} | IntervalThrottle = {IntervalThrottle} | IntervalExecutionCount = {IntervalExecutionCount}"; } } } \ No newline at end of file diff --git a/4x/Move Mouse/Actions/CommandAction.cs b/4x/Move Mouse/Actions/CommandAction.cs index 1ffd2c6..31b0789 100644 --- a/4x/Move Mouse/Actions/CommandAction.cs +++ b/4x/Move Mouse/Actions/CommandAction.cs @@ -88,7 +88,7 @@ public override void Execute() public override string ToString() { - return $"Name = {Name} | FilePath = {FilePath} | Arguments = {Arguments} | WaitForExit = {WaitForExit} | Hidden = {Hidden} | Trigger = {Trigger} | Repeat = {Repeat}"; + return $"{this.GetType().Name} | Name = {Name} | FilePath = {FilePath} | Arguments = {Arguments} | WaitForExit = {WaitForExit} | Hidden = {Hidden} | Trigger = {Trigger} | Repeat = {Repeat} | RepeatMode = {RepeatMode} | IntervalThrottle = {IntervalThrottle} | IntervalExecutionCount = {IntervalExecutionCount}"; } } } \ No newline at end of file diff --git a/4x/Move Mouse/Actions/MoveMouseCursorAction.cs b/4x/Move Mouse/Actions/MoveMouseCursorAction.cs index 20218cc..25c9f6e 100644 --- a/4x/Move Mouse/Actions/MoveMouseCursorAction.cs +++ b/4x/Move Mouse/Actions/MoveMouseCursorAction.cs @@ -125,6 +125,7 @@ public override void Execute() { try { + IntervalExecutionCount++; StaticCode.Logger?.Here().Information(ToString()); switch (Direction) @@ -236,7 +237,7 @@ public override void Execute() public override string ToString() { - return $"Name = {Name} | Distance = {Distance} | Direction = {Direction} | Speed = {Speed} | Delay = {Delay} | Trigger = {Trigger} | Repeat = {Repeat}"; + return $"{this.GetType().Name} | Name = {Name} | Distance = {Distance} | Direction = {Direction} | Speed = {Speed} | Delay = {Delay} | Trigger = {Trigger} | Repeat = {Repeat} | RepeatMode = {RepeatMode} | IntervalThrottle = {IntervalThrottle} | IntervalExecutionCount = {IntervalExecutionCount}"; } } } \ No newline at end of file diff --git a/4x/Move Mouse/Actions/PositionMouseCursorAction.cs b/4x/Move Mouse/Actions/PositionMouseCursorAction.cs index 7ea7acd..9e920e2 100644 --- a/4x/Move Mouse/Actions/PositionMouseCursorAction.cs +++ b/4x/Move Mouse/Actions/PositionMouseCursorAction.cs @@ -127,7 +127,7 @@ private void _cursorTrackingTimer_Elapsed(object sender, ElapsedEventArgs e) public override string ToString() { - return $"Name = {Name} | X = {X} | Y = {Y} | Trigger = {Trigger} | Repeat = {Repeat}"; + return $"{this.GetType().Name} | Name = {Name} | X = {X} | Y = {Y} | Trigger = {Trigger} | Repeat = {Repeat} | RepeatMode = {RepeatMode} | IntervalThrottle = {IntervalThrottle} | IntervalExecutionCount = {IntervalExecutionCount}"; } } } \ No newline at end of file diff --git a/4x/Move Mouse/Actions/ScriptAction.cs b/4x/Move Mouse/Actions/ScriptAction.cs index dd37ec7..79ad77a 100644 --- a/4x/Move Mouse/Actions/ScriptAction.cs +++ b/4x/Move Mouse/Actions/ScriptAction.cs @@ -80,7 +80,7 @@ public override void Execute() public override string ToString() { - return $"Name = {Name} | ScriptPath = {ScriptPath} | WaitForExit = {WaitForExit} | Hidden = {Hidden} | Trigger = {Trigger} | Repeat = {Repeat}"; + return $"{this.GetType().Name} | Name = {Name} | ScriptPath = {ScriptPath} | WaitForExit = {WaitForExit} | Hidden = {Hidden} | Trigger = {Trigger} | Repeat = {Repeat} | RepeatMode = {RepeatMode} | IntervalThrottle = {IntervalThrottle} | IntervalExecutionCount = {IntervalExecutionCount}"; } } } \ No newline at end of file diff --git a/4x/Move Mouse/Actions/ScrollMouseAction.cs b/4x/Move Mouse/Actions/ScrollMouseAction.cs index 946de81..2283df4 100644 --- a/4x/Move Mouse/Actions/ScrollMouseAction.cs +++ b/4x/Move Mouse/Actions/ScrollMouseAction.cs @@ -92,7 +92,7 @@ public override void Execute() public override string ToString() { - return $"Name = {Name} | Distance = {Distance} | Direction = {Direction} | Trigger = {Trigger} | Repeat = {Repeat}"; + return $"{this.GetType().Name} | Name = {Name} | Distance = {Distance} | Direction = {Direction} | Trigger = {Trigger} | Repeat = {Repeat} | RepeatMode = {RepeatMode} | IntervalThrottle = {IntervalThrottle} | IntervalExecutionCount = {IntervalExecutionCount}"; } } } \ No newline at end of file diff --git a/4x/Move Mouse/Actions/SleepAction.cs b/4x/Move Mouse/Actions/SleepAction.cs index 5e75bd9..828891b 100644 --- a/4x/Move Mouse/Actions/SleepAction.cs +++ b/4x/Move Mouse/Actions/SleepAction.cs @@ -78,7 +78,7 @@ public override void Execute() public override string ToString() { - return $"Name = {Name} | Random = {Random} | Seconds = {Seconds} | UpperSeconds = {UpperSeconds} | Trigger = {Trigger} | Repeat = {Repeat}"; + return $"{this.GetType().Name} | Name = {Name} | Random = {Random} | Seconds = {Seconds} | UpperSeconds = {UpperSeconds} | Trigger = {Trigger} | Repeat = {Repeat} | RepeatMode = {RepeatMode} | IntervalThrottle = {IntervalThrottle} | IntervalExecutionCount = {IntervalExecutionCount}"; } } } \ No newline at end of file diff --git a/4x/Move Mouse/Classes/Settings.cs b/4x/Move Mouse/Classes/Settings.cs index c8a9264..64f385f 100644 --- a/4x/Move Mouse/Classes/Settings.cs +++ b/4x/Move Mouse/Classes/Settings.cs @@ -52,6 +52,7 @@ public class Settings : INotifyPropertyChanged private bool? _pauseOnBattery; private LogEventLevel? _logLevel; private bool? _showSystemTrayNotifications; + //private bool? _reactivatePreviousWindow; public int LowerInterval { @@ -535,6 +536,20 @@ public bool ShowSystemTrayNotifications } } + //public bool ReactivatePreviousWindow + //{ + // get + // { + // if (_reactivatePreviousWindow == null) _reactivatePreviousWindow = false; + // return _reactivatePreviousWindow.Value; + // } + // set + // { + // _reactivatePreviousWindow = value; + // OnPropertyChanged(); + // } + //} + [XmlArrayItem(Type = typeof(ActionBase)), XmlArrayItem(Type = typeof(MoveMouseCursorAction)), XmlArrayItem(Type = typeof(ClickMouseAction)), diff --git a/4x/Move Mouse/Properties/AssemblyInfo.cs b/4x/Move Mouse/Properties/AssemblyInfo.cs index d6afcdd..6ea4ffe 100644 --- a/4x/Move Mouse/Properties/AssemblyInfo.cs +++ b/4x/Move Mouse/Properties/AssemblyInfo.cs @@ -51,5 +51,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("4.15.1.0")] -[assembly: AssemblyFileVersion("4.15.1.0")] +[assembly: AssemblyVersion("4.16.0.0")] +[assembly: AssemblyFileVersion("4.16.0.0")] diff --git a/4x/Move Mouse/StaticCode.cs b/4x/Move Mouse/StaticCode.cs index d41690a..4dda8dc 100644 --- a/4x/Move Mouse/StaticCode.cs +++ b/4x/Move Mouse/StaticCode.cs @@ -23,10 +23,11 @@ public static class StaticCode public const string PayPalUrl = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZTWHD9CRW5XN"; public const string HomePageUrl = "http://www.movemouse.co.uk"; - public const string HelpPageUrl = "https://sites.google.com/a/windandkite.co.uk/movemouse/help"; + public const string HelpPageUrl = "https://github.com/sw3103/movemouse/wiki"; public const string TwitterUrl = "https://twitter.com/movemouse"; public const string GitHubUrl = "https://github.com/sw3103/movemouse"; public const string CronHelpUrl = "http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html"; + public const string TroubleshootingUrl = "https://github.com/sw3103/movemouse/wiki/Troubleshooting"; //public const string CronHelpUrl = "https://crontab.guru/examples.html"; //public const string ThemesXmlUrl = "https://raw.githubusercontent.com/sw3103/movemouse/master/Themes/Themes.xml"; //public const string ThemesXmlUrl = "C:\\Users\\steve\\source\\repos\\movemouse\\Themes\\Themes_Test.xml"; diff --git a/4x/Move Mouse/ViewModels/MouseWindowViewModel.cs b/4x/Move Mouse/ViewModels/MouseWindowViewModel.cs index f99d96d..d159d7b 100644 --- a/4x/Move Mouse/ViewModels/MouseWindowViewModel.cs +++ b/4x/Move Mouse/ViewModels/MouseWindowViewModel.cs @@ -4,14 +4,18 @@ using ellabi.Jobs; using ellabi.Schedules; using ellabi.Utilities; +using ellabi.Wrappers; +using Microsoft.VisualBasic; using Microsoft.Win32; using Quartz; using Quartz.Impl; using Quartz.Impl.Triggers; using System; using System.ComponentModel; +using System.Diagnostics; using System.Linq; using System.Runtime.CompilerServices; +using System.Text; using System.Threading; namespace ellabi.ViewModels @@ -61,6 +65,7 @@ internal class MouseWindowViewModel : INotifyPropertyChanged, IDisposable private object _lock = new object(); private bool _updateAvailable; //private DateTime _startTime; + //private string _previousActiveWindowTitle; public enum MouseState { @@ -491,7 +496,7 @@ public void Start() _activeExecutionId = Guid.NewGuid(); _lastStopStartToggleTime = DateTime.Now; PerformActions(ActionBase.EventTrigger.Start); - double interval = SettingsVm.Settings.RandomInterval ? new Random().Next((SettingsVm.Settings.LowerInterval * 1000), (SettingsVm.Settings.UpperInterval * 1000)) : (SettingsVm.Settings.LowerInterval * 1000); + double interval = SettingsVm.Settings.RandomInterval ? new Random().Next(SettingsVm.Settings.LowerInterval * 1000, SettingsVm.Settings.UpperInterval * 1000) : (SettingsVm.Settings.LowerInterval * 1000); interval = interval > 0 ? interval : 1; ExecutionTime = DateTime.Now.AddMilliseconds(interval); CurrentState = MouseState.Running; @@ -515,6 +520,26 @@ public void Start() } } + //private void GetActiveWindow() + //{ + // try + // { + // var handle = NativeMethods.GetForegroundWindow(); + // const int nChar = 256; + // var sb = new StringBuilder(nChar); + // _previousActiveWindowTitle = null; + + // if (NativeMethods.GetWindowText(handle, sb, nChar) > 0) + // { + // _previousActiveWindowTitle = sb.ToString(); + // } + // } + // catch (Exception ex) + // { + // StaticCode.Logger?.Here().Error(ex.Message); + // } + //} + public void Stop(MouseState state) { StaticCode.Logger?.Here().Information(state.ToString()); @@ -543,6 +568,11 @@ public void Stop(MouseState state) if (CurrentState.Equals(MouseState.Paused)) { StartAutoResumeTimer(); + + //if (SettingsVm.Settings.ReactivatePreviousWindow && !String.IsNullOrWhiteSpace(_previousActiveWindowTitle)) + //{ + // Interaction.AppActivate(_previousActiveWindowTitle); + //} } } } @@ -613,6 +643,14 @@ private void PerformActions(ActionBase.EventTrigger trigger) { var executionId = _activeExecutionId; + if (_firstPass) + { + for (int i = 0; i < SettingsVm.Settings.Actions.Length; i++) + { + SettingsVm.Settings.Actions[i].IntervalExecutionCount = 0; + } + } + switch (trigger) { case ActionBase.EventTrigger.Start: @@ -643,7 +681,7 @@ private void PerformActions(ActionBase.EventTrigger trigger) if (SettingsVm.Settings.Actions.Any(action => action.IsValid && action.IsEnabled && action.Trigger.Equals(trigger))) { - var actions = _firstPass ? SettingsVm.Settings.Actions.Where(action => action.IsValid && action.IsEnabled && action.Trigger.Equals(trigger)) : SettingsVm.Settings.Actions.Where(action => action.IsValid && action.IsEnabled && action.Trigger.Equals(trigger) && action.Repeat); + var actions = _firstPass ? SettingsVm.Settings.Actions.Where(action => action.IsValid && action.IsEnabled && action.Trigger.Equals(trigger)) : SettingsVm.Settings.Actions.Where(action => action.IsValid && action.IsEnabled && action.Trigger.Equals(trigger) && action.Repeat && ((action.RepeatMode == ActionBase.IntervalRepeatMode.Forever) || ((action.RepeatMode == ActionBase.IntervalRepeatMode.Throttle) && (action.IntervalExecutionCount < action.IntervalThrottle)))); foreach (var action in actions) { @@ -666,19 +704,14 @@ private void PerformActions(ActionBase.EventTrigger trigger) CurrentState = MouseState.Locked; } - if (_activeExecutionId.Equals(executionId) && (CurrentState.Equals(MouseState.Sleeping) || (!_firstPass && SettingsVm.Settings.Actions.Any(action => action.IsValid && action.IsEnabled && action.Trigger.Equals(trigger) && action.Repeat)))) + if (_activeExecutionId.Equals(executionId) && (CurrentState.Equals(MouseState.Locked) || CurrentState.Equals(MouseState.Sleeping) || (!_firstPass && SettingsVm.Settings.Actions.Any(action => action.IsValid && action.IsEnabled && action.Trigger.Equals(trigger) && action.Repeat && ((action.RepeatMode == ActionBase.IntervalRepeatMode.Forever) || ((action.RepeatMode == ActionBase.IntervalRepeatMode.Throttle) && (action.IntervalExecutionCount < action.IntervalThrottle))))))) { Start(); - - if (CurrentState.Equals(MouseState.Sleeping)) - { - ShowNotification("Automatically resuming after blackout expired."); - } } else { Stop(MouseState.Idle); - ShowNotification("Automatically stopping as there are no actions that are configured to repeat at each interval."); + ShowNotification("Automatically stopping as there are no actions that are configured to repeat forever at each interval."); } break; @@ -805,6 +838,7 @@ private void _autoResumeTimer_Elapsed(object sender, System.Timers.ElapsedEventA if (StaticCode.GetLastInputTime().TotalSeconds > SettingsVm.Settings.AutoResumeSeconds) { Start(); + //GetActiveWindow(); ShowNotification($"Automatically resuming after {SettingsVm.Settings.AutoResumeSeconds} seconds of inactivity."); } } @@ -821,6 +855,7 @@ private void StartBlackoutTimer() try { StopBlackoutTimer(); + ShowNotification("Going to sleep whilst blackout in effect."); if (_blackoutTimer == null) { @@ -862,7 +897,7 @@ private void _blackoutTimer_Elapsed(object sender, System.Timers.ElapsedEventArg if (!BlackoutIsActive()) { Start(); - ShowNotification("Resuming now blackout is over."); + ShowNotification("Resuming now blackout has expired."); } } catch (Exception ex) @@ -914,7 +949,7 @@ public void ShowNotification(string message) public void ShowNotification(string title, string message, Hardcodet.Wpf.TaskbarNotification.BalloonIcon symbol) { - if (!SettingsVm.Settings.HideSystemTrayIcon && SettingsVm.Settings.ShowSystemTrayNotifications) + if (!SettingsVm.Settings.HideSystemTrayIcon && SettingsVm.Settings.ShowSystemTrayNotifications && !_workstationLocked) { OnRequestNotification(this, title, message, symbol); } diff --git a/4x/Move Mouse/Views/MouseWindow.xaml b/4x/Move Mouse/Views/MouseWindow.xaml index 96c05d6..9b596af 100644 --- a/4x/Move Mouse/Views/MouseWindow.xaml +++ b/4x/Move Mouse/Views/MouseWindow.xaml @@ -307,7 +307,7 @@ - + diff --git a/4x/Move Mouse/Views/MouseWindow.xaml.cs b/4x/Move Mouse/Views/MouseWindow.xaml.cs index 5289334..cb41e53 100644 --- a/4x/Move Mouse/Views/MouseWindow.xaml.cs +++ b/4x/Move Mouse/Views/MouseWindow.xaml.cs @@ -547,19 +547,19 @@ private void UpdateCallout_OnMouseDown(object sender, MouseButtonEventArgs e) // return IntPtr.Zero; //} - private void ContactButton_OnClick(object sender, RoutedEventArgs e) - { - StaticCode.Logger?.Here().Debug(String.Empty); + //private void ContactButton_OnClick(object sender, RoutedEventArgs e) + //{ + // StaticCode.Logger?.Here().Debug(String.Empty); - try - { - Process.Start(StaticCode.ContactMailToAddress); - } - catch (Exception ex) - { - StaticCode.Logger?.Here().Error(ex.Message); - } - } + // try + // { + // Process.Start(StaticCode.ContactMailToAddress); + // } + // catch (Exception ex) + // { + // StaticCode.Logger?.Here().Error(ex.Message); + // } + //} private void MouseWindow_OnClosing(object sender, CancelEventArgs e) { diff --git a/4x/Move Mouse/Views/SettingsWindow.xaml b/4x/Move Mouse/Views/SettingsWindow.xaml index 3be0a86..310de4b 100644 --- a/4x/Move Mouse/Views/SettingsWindow.xaml +++ b/4x/Move Mouse/Views/SettingsWindow.xaml @@ -12,7 +12,7 @@ xmlns:classes="clr-namespace:ellabi.Classes" xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing" mc:Ignorable="d" - Title="Move Mouse Settings" Height="442" Width="640" Icon="/Resources/Mouse.ico" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize" WindowStyle="None" MouseDown="SettingsWindow_OnMouseDown" ShowActivated="True" Loaded="SettingsWindow_OnLoaded"> + Title="Move Mouse Settings" Height="442" Width="688" Icon="/Resources/Mouse.ico" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize" WindowStyle="None" MouseDown="SettingsWindow_OnMouseDown" ShowActivated="True" Loaded="SettingsWindow_OnLoaded"> @@ -626,13 +626,19 @@ - + + + + + + + @@ -650,6 +656,40 @@ + + + + + + + + + + + @@ -1175,7 +1215,7 @@ - + @@ -1227,7 +1267,7 @@ - + @@ -1344,9 +1384,24 @@ - diff --git a/4x/Move Mouse/Views/SettingsWindow.xaml.cs b/4x/Move Mouse/Views/SettingsWindow.xaml.cs index 9fafed6..c3a190e 100644 --- a/4x/Move Mouse/Views/SettingsWindow.xaml.cs +++ b/4x/Move Mouse/Views/SettingsWindow.xaml.cs @@ -300,7 +300,16 @@ private void ContactLink_OnMouseDown(object sender, MouseButtonEventArgs e) try { - Process.Start(StaticCode.ContactMailToAddress); + var result = MessageBox.Show("If you are having issues with Move Mouse or have any questions, you may find the Troubleshooting section in the Wiki useful.\r\n\r\nWould you like to visit the Wiki now?", "Visit Troubleshooting Page", MessageBoxButton.YesNo, MessageBoxImage.Question); + + if (result == MessageBoxResult.Yes) + { + Process.Start(StaticCode.TroubleshootingUrl); + } + else + { + Process.Start(StaticCode.ContactMailToAddress); + } } catch (Exception ex) { diff --git a/4x/Move Mouse/Wrappers/NativeMethods.cs b/4x/Move Mouse/Wrappers/NativeMethods.cs index 7d7dd12..a2825b1 100644 --- a/4x/Move Mouse/Wrappers/NativeMethods.cs +++ b/4x/Move Mouse/Wrappers/NativeMethods.cs @@ -1,13 +1,14 @@ using System; using System.Drawing; using System.Runtime.InteropServices; +using System.Text; // ReSharper disable InconsistentNaming // ReSharper disable MemberCanBePrivate.Local // ReSharper disable FieldCanBeMadeReadOnly.Local namespace ellabi.Wrappers { - internal class NativeMethods + public class NativeMethods { //public const int WH_KEYBOARD_LL = 13; @@ -159,18 +160,6 @@ public struct WINDOWPLACEMENT IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl); - //[DllImport("user32.dll", EntryPoint = "SetWindowLongPtr", SetLastError = true)] - //private static extern IntPtr IntSetWindowLongPtr( - // IntPtr hWnd, - // int nIndex, - // IntPtr dwNewLong); - - //[DllImport("user32.dll", EntryPoint = "SetWindowLong", SetLastError = true)] - //private static extern Int32 IntSetWindowLong( - // IntPtr hWnd, - // int nIndex, - // Int32 dwNewLong); - [DllImport("kernel32.dll", EntryPoint = "SetLastError")] public static extern void SetLastError( int dwErrorCode); @@ -186,19 +175,13 @@ public struct WINDOWPLACEMENT int nIndex, int dwNewLong); - //[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] - //public static extern IntPtr SetWindowsHookEx( - // int idHook, - // LowLevelKeyboardProc lpfn, - // IntPtr hMod, - // uint dwThreadId); - - //[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] - //public static extern bool UnhookWindowsHookEx( - // IntPtr hhk); + [DllImport("user32.dll")] + public static extern IntPtr GetForegroundWindow(); - //[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] - //public static extern IntPtr GetModuleHandle( - // string lpModuleName); + [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] + public static extern int GetWindowText( + IntPtr hWnd, + StringBuilder lpString, + int nMaxCount); } } \ No newline at end of file