A simple tool that leverages the OpenAI API to translate text on the screen when a shortcut is pressed.
The shortcut in this case is hardcoded as Shift + Ctrl + PrtScr. The prompt, however, is customizeable and is in prompt.md
.
If you just want to run it, jump to section Running.
To use this app, first install Python 3.11. Then, populate the .env
file with your OpenAI API key.
Refer to .env.example
for a reference.
After that, enable the virtual environment and set everything up:
Windows (PowerShell)
py -3.11 -m venv .venv # Create the environment if you haven't already
.venv\Scripts\Activate.ps1 # Activate it
pip install -r .\requirements.txt # Install all requirements
You can then either run the app directly:
python .\tray_translate_picker.py
Or build it into a standalone .exe
with:
pyinstaller --onefile --noconsole tray_translate_picker.py
# Or to include a custom prompt
pyinstaller --onefile --noconsole --add-data "prompt.md;." tray_translate_picker.py
If you download the prebuilt release and/or run the standalone executable, make sure to have the .env
in the same directory. If you use the prebuilt release, note that prompt.md
gets ignored, and a fallback "Image-to-English" prompt will be used, unless the prompt is explicitly bundled/included with pyinstaller.