From 5d016eb7737b9de05f0c5ae5d9343f9f6d5fef82 Mon Sep 17 00:00:00 2001 From: Justin Lin <61717681+justinlin099@users.noreply.github.com> Date: Sun, 26 May 2024 01:21:04 +0800 Subject: [PATCH] Add middle mouse button remap --- FrameworkKeyCenter.py | 9 +++++++-- FrameworkKeyService.py | 7 +++++++ NSIS.nsi | 4 +++- 3 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 FrameworkKeyService.py diff --git a/FrameworkKeyCenter.py b/FrameworkKeyCenter.py index 7f66955..57903d3 100644 --- a/FrameworkKeyCenter.py +++ b/FrameworkKeyCenter.py @@ -16,7 +16,8 @@ RICK_ROLL_LOCATION = "C:\Program Files\FrameworkKeyCenter\components\\NGGYU\\NGGYU.exe" CLIPBOARD_CONTROL_LOCATION = "C:\Program Files\FrameworkKeyCenter\components\CopyandPaste\CopyandPaste.exe" TRACKPAD_CONTROL_LOCATION = "C:\Program Files\FrameworkKeyCenter\components\TouchPadToggle\TouchPadToggle.exe" -VERSION='Version: 1.0.4' +FRAMEWORK_KEY_SERVICE = "C:\Program Files\FrameworkKeyCenter\components\FrameworkKeyService\FrameworkKeyService.exe" +VERSION='Version: 1.0.5' current_opaque = 0 @@ -68,6 +69,8 @@ def apply(): winreg.SetValueEx(key, 'ShellExecute', 0, winreg.REG_SZ, customWeblinkEntry.get()) elif(dropDown.current() == 5): winreg.SetValueEx(key, 'ShellExecute', 0, winreg.REG_SZ, TRACKPAD_CONTROL_LOCATION) + elif(dropDown.current() == 8): + winreg.SetValueEx(key, 'ShellExecute', 0, winreg.REG_SZ, FRAMEWORK_KEY_SERVICE) winreg.CloseKey(key) except FileNotFoundError: @@ -89,6 +92,8 @@ def apply(): winreg.SetValueEx(key, 'ShellExecute', 0, winreg.REG_SZ, customWeblinkEntry.get()) elif(dropDown.current() == 5): winreg.SetValueEx(key, 'ShellExecute', 0, winreg.REG_SZ, TRACKPAD_CONTROL_LOCATION) + elif(dropDown.current() == 8): + winreg.SetValueEx(key, 'ShellExecute', 0, winreg.REG_SZ, FRAMEWORK_KEY_SERVICE) winreg.CloseKey(key) else: print('Switch is off') @@ -243,7 +248,7 @@ def opaque_window(): dropDownLabel = ttk.Label(dropDownFrame, text='Select an action', font=('Segoe UI', 10)) dropDownLabel.pack(side='left', padx=10) -dropDown = ttk.Combobox(dropDownFrame, values=['Screen Rotation', 'Copilot Key', 'TaskManager', 'RickRoll', 'Copy and Paste (Clipboard Control)', 'Enable/Disable TrackPad', 'Custom Application', 'Custom Link'], state='readonly') +dropDown = ttk.Combobox(dropDownFrame, values=['Screen Rotation', 'Copilot Key', 'TaskManager', 'RickRoll', 'Copy and Paste (Clipboard Control)', 'Enable/Disable TrackPad', 'Custom Application', 'Custom Link', 'Middle Mouse Button'], state='readonly') dropDown.pack(side='right', fill='x', expand=True, padx=10) dropDown.current(0) dropDown.bind('<>', selectDropDown) diff --git a/FrameworkKeyService.py b/FrameworkKeyService.py new file mode 100644 index 0000000..912733c --- /dev/null +++ b/FrameworkKeyService.py @@ -0,0 +1,7 @@ +import keyboard +import mouse + +keyboard.on_press_key(109, lambda x: mouse.press('middle'),suppress=True) # F2 +keyboard.on_release_key(109, lambda x: mouse.release('middle'),suppress=True) # F2 + +keyboard.wait() \ No newline at end of file diff --git a/NSIS.nsi b/NSIS.nsi index 76aa992..856dacb 100644 --- a/NSIS.nsi +++ b/NSIS.nsi @@ -19,7 +19,7 @@ Name "Framework Key Center" -OutFile "FrameworkKeyCenterInstaller-v1.0.4.exe" +OutFile "FrameworkKeyCenterInstaller-v1.0.5.exe" ; Request application privileges for Windows Vista and higher RequestExecutionLevel admin @@ -74,6 +74,8 @@ Section "Framework Key Center (required)" File /r "dist\TouchpadToggle" + File /r "dist\FrameworkKeyService" + AccessControl::GrantOnFile "$INSTDIR\components" "(BU)" "FullAccess" ; Write the installation path into the registry