Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: shortcuts for checking box and "patch game" button, and more #93

Open
dgdg123 opened this issue Mar 26, 2022 · 2 comments
Open

Comments

@dgdg123
Copy link

dgdg123 commented Mar 26, 2022

I like to speed up the game 500% when I die in a boss and gonna have to wait 30s in the "you died" screen, plus loading, plus walking from the check point to the boss room and slow the game back to the default speed when I enter fight is going to start. Its a pain in the ass to do that right now, some shortcuts for those options would be amazing.

the "disable camera auto rotate on movement" worked but I cant disable the feature after I enable it. The box is unchecked, I patched the game but the camera behavior still is "patched". Tried to close the game and reopening it and didnt manage to revert the game back to the default camera behavior. I will check a bit more and post here if anything changes about that.

@dcealopez
Copy link

This PR should fix the camera auto rotate disable not working: #111

@smcpeak
Copy link

smcpeak commented Jul 7, 2023

For my own use, I've hacked in a hotkey to toggle the game speed adjustment. The diff is below (although it won't apply automatically with patch due to unrelated factoring I did nearby). If there is interest, I could make the key customizable and submit a PR.

diff --git a/EldenRingFPSUnlockAndMore/MainWindow.xaml.cs b/EldenRingFPSUnlockAndMore/MainWindow.xaml.cs
index e3b3b95..5762826 100644
--- a/EldenRingFPSUnlockAndMore/MainWindow.xaml.cs
+++ b/EldenRingFPSUnlockAndMore/MainWindow.xaml.cs
@@ -15,6 +15,8 @@ using System.Management;
 using System.Text.RegularExpressions;
 using System.Collections.Generic;
 using System.Security.Principal;
+using System.Windows.Input;
+using System.Windows.Interop;
 
 namespace EldenRingFPSUnlockAndMore
 {
@@ -69,6 +71,17 @@ namespace EldenRingFPSUnlockAndMore
         internal readonly DispatcherTimer _dispatcherTimerGameCheck = new DispatcherTimer(DispatcherPriority.Send);
         internal readonly BackgroundWorker _bgwScanGame = new BackgroundWorker();
 
+        /// <summary>
+        /// True if the speed toggle hotkey is registered.
+        /// </summary>
+        internal bool _registeredHotKey = false;
+
+        // Hotkey registration functions.
+        [DllImport("user32.dll")]
+        private static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk);
+        [DllImport("user32.dll")]
+        private static extern bool UnregisterHotKey(IntPtr hWnd, int id);
+
         public MainWindow()
         {
             InitializeComponent();
@@ -85,6 +98,21 @@ namespace EldenRingFPSUnlockAndMore
                 Directory.CreateDirectory(appdir);
             _path_logs = Path.Combine(appdir, "logs.log");
 
+            // Register a global hotkey (F4) to toggle the speed change in-game.
+            IntPtr myWindowHandle = new WindowInteropHelper(this).Handle;
+            if (RegisterHotKey(myWindowHandle, 1 /*id*/, 0, 0x73 /*F4*/))
+            {
+                _registeredHotKey = true;
+
+                // Arrange to intercept the resulting WM_HOTKEY messages.
+                HwndSource source = HwndSource.FromHwnd(myWindowHandle);
+                source.AddHook(new HwndSourceHook(WndProc));
+            }
+            else
+            {
+                LogToFile("RegisterHotKey failed");
+            }
+
             var mutex = new Mutex(true, "ErFpsUnlockAndMore", out bool isNewInstance);
             if (!isNewInstance)
             {
@@ -142,6 +170,25 @@ namespace EldenRingFPSUnlockAndMore
                 }
                 catch { }
             }
+
+            if (_registeredHotKey)
+            {
+                IntPtr myWindowHandle = new WindowInteropHelper(this).Handle;
+                UnregisterHotKey(myWindowHandle, 1 /*id*/);
+            }
+        }
+
+        // Intercepted window message handler.
+        private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
+        {
+            const int WM_HOTKEY = 0x0312;
+            if (msg == WM_HOTKEY)
+            {
+                ToggleGameSpeed();
+                handled = true;
+            }
+
+            return IntPtr.Zero;
         }
 
         /// <summary>
@@ -812,6 +859,13 @@ namespace EldenRingFPSUnlockAndMore
             return true;
         }
 
+        // Toggle the game speed checkbox, then re-patch.
+        private void ToggleGameSpeed()
+        {
+            cbGameSpeed.IsChecked = !cbGameSpeed.IsChecked;
+            PatchGameSpeed();
+        }
+
         /// <summary>
         /// Checks if the user has called this application as administrator.
         /// </summary>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants