diff --git a/config.json b/config.json index 6b90feb..f005e16 100644 --- a/config.json +++ b/config.json @@ -1,5 +1,5 @@ { - "run_on_startup": true, + "run_on_startup": false, "shortcut": "ctrl+shift+B", "lang_change": true } \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 5d88c10..a3f5d18 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ keyboard==0.13.5 pyperclip==1.9.0 pystray==0.19.5 -Pillow==11.3.0 \ No newline at end of file +Pillow \ No newline at end of file diff --git a/run.bat b/run.bat index 2f820d2..149adb0 100644 --- a/run.bat +++ b/run.bat @@ -1,4 +1,4 @@ -@echo off + cd /d "%~dp0" call venv\Scripts\activate.bat diff --git a/src/__pycache__/config.cpython-314.pyc b/src/__pycache__/config.cpython-314.pyc new file mode 100644 index 0000000..ec0b4af Binary files /dev/null and b/src/__pycache__/config.cpython-314.pyc differ diff --git a/src/__pycache__/main.cpython-314.pyc b/src/__pycache__/main.cpython-314.pyc new file mode 100644 index 0000000..6202d0d Binary files /dev/null and b/src/__pycache__/main.cpython-314.pyc differ diff --git a/src/__pycache__/startup.cpython-314.pyc b/src/__pycache__/startup.cpython-314.pyc new file mode 100644 index 0000000..2ee3900 Binary files /dev/null and b/src/__pycache__/startup.cpython-314.pyc differ diff --git a/src/main.pyw b/src/main.pyw index 33c97cb..c78c872 100644 --- a/src/main.pyw +++ b/src/main.pyw @@ -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