Updating to fix a bug with app macros

This commit is contained in:
jknapp 2025-03-23 08:44:25 -07:00
parent 2dcc74f9d4
commit 4aa5ce1ff2
3 changed files with 25 additions and 19 deletions

BIN
dist/mp-server-v2.exe vendored

Binary file not shown.

View File

@ -15,6 +15,7 @@ import logging
import socket
import qrcode
import sys
import time
class MacroPadServer:
def __init__(self, root):
@ -22,6 +23,9 @@ class MacroPadServer:
self.root.title("MacroPad Server")
self.root.geometry("800x600")
self.configure_styles()
# Set Version Str
self.version_str = "0.5.3 Beta"
# Set up directories
if getattr(sys, 'frozen', False):
@ -85,6 +89,12 @@ class MacroPadServer:
right_frame = ttk.Frame(main_frame)
right_frame.pack(side=tk.RIGHT, fill=tk.BOTH, expand=True, padx=(10, 0))
#Set version details
version_label = tk.Label(self.root, text=self.version_str,
bg=self.bg_color, fg=self.fg_color,
font=('Helvetica', 8)) # Using smaller font for version text
version_label.pack(side=tk.BOTTOM, anchor=tk.SE, padx=5, pady=(0, 2))
# Button container
button_frame = ttk.Frame(left_frame)
button_frame.pack(fill=tk.X, pady=(0, 10))
@ -886,32 +896,26 @@ setTimeout(() => { errorStatus.style.display = 'none'; }, 2000);
if macro["type"] == "text":
# Handle key modifiers
modifiers = macro.get("modifiers", {})
keys_to_press = []
# Add modifier keys if enabled
if modifiers.get("ctrl", False):
keys_to_press.append('ctrl')
pyautogui.keyDown('ctrl')
if modifiers.get("alt", False):
keys_to_press.append('alt')
pyautogui.keyDown('alt')
if modifiers.get("shift", False):
keys_to_press.append('shift')
# If there are modifier keys, use hotkey functionality
if keys_to_press:
# For single characters with modifiers, use hotkey
if len(macro["command"]) == 1:
keys_to_press.append(macro["command"])
pyautogui.hotkey(*keys_to_press)
else:
# For longer text, press modifiers, type text, then release
for key in keys_to_press:
pyautogui.keyDown(key)
pyautogui.typewrite(macro["command"], interval=0.02)
for key in reversed(keys_to_press):
pyautogui.keyUp(key)
pyautogui.keyDown('shift')
if str(macro["command"]) and len(str(macro["command"])) == 1:
pyautogui.keyDown(macro["command"])
time.sleep(0.5)
else:
# No modifiers, just type the text
pyautogui.typewrite(macro["command"], interval=0.02)
# Release modifier keys in reverse order
if modifiers.get("shift", False):
pyautogui.keyUp('shift')
if modifiers.get("alt", False):
pyautogui.keyUp('alt')
if modifiers.get("ctrl", False):
pyautogui.keyUp('ctrl')
# Add Enter/Return if requested
if modifiers.get("enter", False):
@ -943,6 +947,7 @@ setTimeout(() => { errorStatus.style.display = 'none'; }, 2000);
def exit_app(self, icon=None, item=None):
# Actually exit the app
self.stop_server()
self.server_running = False
if hasattr(self, 'tray_icon'):
self.tray_icon.stop()

1
version.txt Normal file
View File

@ -0,0 +1 @@
0.5.3