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",
|
||||
"lang_change": true
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
keyboard==0.13.5
|
||||
pyperclip==1.9.0
|
||||
pystray==0.19.5
|
||||
Pillow==11.3.0
|
||||
Pillow
|
||||
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))
|
||||
|
||||
# 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
|
||||
|
||||
Reference in New Issue
Block a user