feat: Implement core application logic for text conversion via shortcut with system tray management and update default startup configuration.

This commit is contained in:
Hamed
2025-12-04 16:24:22 +03:30
parent a0f64e50cc
commit d28858e36d
7 changed files with 10 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
{
"run_on_startup": true,
"run_on_startup": false,
"shortcut": "ctrl+shift+B",
"lang_change": true
}

View File

@@ -1,4 +1,4 @@
keyboard==0.13.5
pyperclip==1.9.0
pystray==0.19.5
Pillow==11.3.0
Pillow

View File

@@ -1,4 +1,4 @@
@echo off
cd /d "%~dp0"
call venv\Scripts\activate.bat

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -106,8 +106,8 @@ def _multiple_replace(mapping, text):
return re.sub(pattern, lambda m: mapping[m.group()], str(text))
# Function to handle the keyboard shortcut
def on_shortcut():
"""This function is called when the shortcut is pressed."""
def process_shortcut():
"""This function contains the logic to handle the shortcut."""
orginal_text = pyperclip.paste() # Get the current clipboard content
time.sleep(0.1)
keyboard.press_and_release('ctrl+c') # Simulate pressing Ctrl+C to copy selected text
@@ -125,6 +125,10 @@ def on_shortcut():
if load_config().get("lang_change", True):
# Change the keyboard layout to Persian
keyboard.press_and_release('windows+space')
def on_shortcut():
"""This function is called when the shortcut is pressed."""
threading.Thread(target=process_shortcut).start()
def quit_app(icon, item):
icon.stop()
import os
@@ -173,7 +177,7 @@ def main():
# Register the keyboard shortcut
shortcut = get_shortcut()
keyboard.add_hotkey(shortcut, on_shortcut)
keyboard.add_hotkey(shortcut, on_shortcut, suppress=True)
print(f"Press {shortcut} to convert text to Persian.")
# Keep the script running