feat: Implement core application logic for text conversion via shortcut with system tray management and update default startup configuration.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"run_on_startup": true,
|
"run_on_startup": false,
|
||||||
"shortcut": "ctrl+shift+B",
|
"shortcut": "ctrl+shift+B",
|
||||||
"lang_change": true
|
"lang_change": true
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
keyboard==0.13.5
|
keyboard==0.13.5
|
||||||
pyperclip==1.9.0
|
pyperclip==1.9.0
|
||||||
pystray==0.19.5
|
pystray==0.19.5
|
||||||
Pillow==11.3.0
|
Pillow
|
||||||
2
run.bat
2
run.bat
@@ -1,4 +1,4 @@
|
|||||||
@echo off
|
|
||||||
cd /d "%~dp0"
|
cd /d "%~dp0"
|
||||||
|
|
||||||
call venv\Scripts\activate.bat
|
call venv\Scripts\activate.bat
|
||||||
|
|||||||
BIN
src/__pycache__/config.cpython-314.pyc
Normal file
BIN
src/__pycache__/config.cpython-314.pyc
Normal file
Binary file not shown.
BIN
src/__pycache__/main.cpython-314.pyc
Normal file
BIN
src/__pycache__/main.cpython-314.pyc
Normal file
Binary file not shown.
BIN
src/__pycache__/startup.cpython-314.pyc
Normal file
BIN
src/__pycache__/startup.cpython-314.pyc
Normal file
Binary file not shown.
10
src/main.pyw
10
src/main.pyw
@@ -106,8 +106,8 @@ def _multiple_replace(mapping, text):
|
|||||||
return re.sub(pattern, lambda m: mapping[m.group()], str(text))
|
return re.sub(pattern, lambda m: mapping[m.group()], str(text))
|
||||||
|
|
||||||
# Function to handle the keyboard shortcut
|
# Function to handle the keyboard shortcut
|
||||||
def on_shortcut():
|
def process_shortcut():
|
||||||
"""This function is called when the shortcut is pressed."""
|
"""This function contains the logic to handle the shortcut."""
|
||||||
orginal_text = pyperclip.paste() # Get the current clipboard content
|
orginal_text = pyperclip.paste() # Get the current clipboard content
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
keyboard.press_and_release('ctrl+c') # Simulate pressing Ctrl+C to copy selected text
|
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):
|
if load_config().get("lang_change", True):
|
||||||
# Change the keyboard layout to Persian
|
# Change the keyboard layout to Persian
|
||||||
keyboard.press_and_release('windows+space')
|
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):
|
def quit_app(icon, item):
|
||||||
icon.stop()
|
icon.stop()
|
||||||
import os
|
import os
|
||||||
@@ -173,7 +177,7 @@ def main():
|
|||||||
|
|
||||||
# Register the keyboard shortcut
|
# Register the keyboard shortcut
|
||||||
shortcut = get_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.")
|
print(f"Press {shortcut} to convert text to Persian.")
|
||||||
|
|
||||||
# Keep the script running
|
# Keep the script running
|
||||||
|
|||||||
Reference in New Issue
Block a user