Control your Windows PC from anywhere via Telegram. Send any keyboard combo, browse windows, take screenshots, drive VLC/Netflix, manage processes, and more โ all from your phone.
- What it does
- Highlights
- Quick start
- Detailed setup
- Usage
- Architecture
- Security
- Auto-start on boot (Windows Task Scheduler)
- Building a standalone
.exe - ืืืืข ืืกืืกื ืืขืืจืืช ๐ฎ๐ฑ
- Contributing
- License
Telegram Windows Command Bot turns Telegram into a remote control for your Windows machine. The bot runs as a small Python service on the PC; you send messages to your bot from any Telegram client; the PC executes them and replies. Only the configured owner can issue commands โ everyone else gets a polite multilingual "go away" message and is logged.
It is built around a single killer primitive โ arbitrary keyboard combinations โ so you are never limited to predefined buttons. Anything you can do with a real keyboard, you can trigger remotely.
# 1. Clone
git clone https://github.com/ori-halevi/Telegram-windows-command-bot.git
cd Telegram-windows-command-bot
# 2. Create venv (Python 3.12 recommended)
py -3.12 -m venv venv
.\venv\Scripts\Activate.ps1
python -m pip install --upgrade pip wheel
pip install -r requirements.txt
# 3. Configure secrets
copy .env.example .env
notepad .env # fill BOT_TOKEN, OWNER_CHAT_ID, OWNER_USERNAME
# 4. Run
python main.py
# or simply: run_bot.batNow message your bot on Telegram and tap /start.
- Open Telegram and message @BotFather.
- Send
/newbot, choose a name and a@username. - BotFather returns a token like
1234567890:AAโฆ. Keep it secret.
- Message @userinfobot โ it replies with your numeric ID.
- (Or: send any message to your new bot and visit
https://api.telegram.org/bot<TOKEN>/getUpdatesto see thechat.id.)
# --- Required ---
BOT_TOKEN=1234567890:AA....
OWNER_CHAT_ID=111222333
OWNER_USERNAME=your_telegram_username # without the @
# --- Optional ---
# Authorise additional users (comma-separated)
# EXTRA_OWNER_CHAT_IDS=444555666,777888999
# EXTRA_OWNER_USERNAMES=alice,bob
# Per-chat rate limit, messages per minute (default 60)
# RATE_LIMIT_PER_MINUTE=60
# Default duration for the ๐ฅ Record screen button, in seconds (default 30)
# SCREEN_RECORD_SECONDS=30
# DEBUG | INFO | WARNING | ERROR (default INFO)
# LOG_LEVEL=INFO.\venv\Scripts\Activate.ps1
pip install -r requirements.txtThe bot uses:
| Package | Purpose |
|---|---|
python-telegram-bot[rate-limiter,job-queue]==21.6 |
async Telegram client |
pyautogui, keyboard |
keyboard & hotkey emulation |
pyperclip |
clipboard read/write |
mss, opencv-python, numpy |
screenshots, screen recording, webcam |
psutil |
processes, system metrics |
pygetwindow |
window list / focus / close |
pycaw, comtypes |
master volume |
| (PowerShell + WMI) | screen brightness |
python main.py
# or
.\run_bot.batThe bot logs to logs/bot.log (rotating, max 5 ร 2 MB) and persists state under data/.
1. Free-text โ fastest if you know the combo
k ctrl+alt+del # task manager dialog
k win+shift+s # snip & sketch
k ctrl+shift+esc # task manager direct
k win+e # explorer
k alt+f4 # close window
type ืฉืืื ืขืืื # type Unicode text via clipboard
Aliases: win = windows = meta = cmd, control = ctrl, option = alt, del = delete, esc = escape, pgup / pgdn, arrowleft etc.
2. Combo Builder โ visual click-to-toggle
3. Macros โ saved sequences
/list_macros # see all macros
/macro task_manager # run a saved one
/save_macro snip win+shift+s # save a single combo
/save_macro flow win+r ; chrome ; enter # save a sequence (semicolons)
/delete_macro snip
Defaults shipped: task_manager, lock, show_desktop, explorer, run, snip, settings, search, action_center, switcher, close_window, new_desktop, next_desktop, prev_desktop.
Tap ๐ Switcher in the main menu. The bot:
- Presses-and-holds
Alt(so the Windows task switcher overlay stays visible), - Presses
Tabonce, - Sends you a screenshot with an inline keyboard.
Then:
| Button | Action |
|---|---|
Tab+1 โก, Tab+2 / 3 / 5 / 10 |
tap forward through windows |
โฌ
Tab-1, Tab-2 / 3 |
tap backward (Shift+Tab) |
โ
Commit (switch) |
release Alt โ focus the highlighted window |
โ Cancel |
press Esc, then release Alt |
๐ Release all |
safety: release any held modifier |
Each tap edits the same photo message in-place with a fresh screenshot, so you watch the switcher overlay update like a real keyboard. If the switcher is left active idle for 120 seconds, the next interaction auto-releases Alt to avoid a stuck modifier. You can also send /release_keys at any time as a manual safety net.
| Command | Meaning |
|---|---|
k <combo> / keys <combo> / hotkey <combo> |
press an arbitrary key combination |
type <text> / t <text> |
type/paste arbitrary Unicode text |
info |
system info (CPU, RAM, disks, uptime, battery) |
lock / sleep / hibernate |
quick power actions |
shutdown [N] / restart [N] / abort_shutdown |
scheduled power (default 5 s delay) |
vol [0-100] / mute |
master volume / toggle mute |
bright [0-100] |
screen brightness |
mouse [pos|move x y|click [left|right]|scroll N] |
mouse control |
ps / kill <name|pid> |
process list / terminate |
focus <title> / close <title> |
window manager |
ls [path] / pwd / cd <path> / download <path> |
file browsing & upload |
wifi / ip |
Wi-Fi info / local & public IP |
copy <text> / paste |
clipboard |
cmd <command> / ps1 <command> |
run shell or PowerShell |
launch <program> / url <link> |
open programs / URLs |
/macro <name> / /save_macro / /list_macros / /delete_macro |
macros |
/about |
public info + GitHub link |
/release_keys |
safety: release Alt / Ctrl / Shift / Win |
/help |
full reference inside the bot |
The codebase follows Feature-Sliced Design (FSD) adapted for a Python Telegram bot. Three layers, strict dependency direction features โ core โ shared. Each feature is a self-contained folder; the composition root iterates ALL_FEATURES and calls feature.register(app) on each.
project/
โโโ main.py # entry point
โโโ run_bot.bat
โโโ app/
โ โโโ composition.py # build_app() โ wires every feature into the Application
โ โ
โ โโโ shared/ # zero-domain utilities
โ โ โโโ atomic_json.py
โ โ โโโ logging.py
โ โ โโโ telegram_utils.py
โ โ
โ โโโ core/ # bot-wide concerns (depends only on shared/)
โ โ โโโ config.py # CONFIG, ROOT, DATA_DIR, LOG_DIR
โ โ โโโ security.py # owner check, rate limiter, intruder log
โ โ โโโ auth.py # @owner_only decorator + alert_intruder
โ โ โโโ messages.py # WELCOME, INTRUDER (12 langs), ABOUT, HELP
โ โ โโโ menu.py # main reply keyboard + label constants
โ โ โโโ router.py # chain-of-responsibility text dispatcher
โ โ โโโ errors.py # global error handler
โ โ โโโ types.py # TextResult dataclass
โ โ
โ โโโ features/ # one folder per feature
โ โโโ start_help/ # /start, /help, /about, /release_keys
โ โโโ keys/ # โจ๏ธ Keys, โจ๏ธ Builder, k <combo>, type
โ โโโ macros/
โ โโโ switcher/ # ๐ interactive Alt+Tab
โ โโโ system/ # ๐ info + ๐ power
โ โโโ audio/ # ๐ volume, mute
โ โโโ brightness/ # ๐ก via PowerShell + WMI
โ โโโ screen/ # ๐ธ + ๐ฅ
โ โโโ webcam/ # ๐ท
โ โโโ mouse/ # cursor / click / scroll
โ โโโ windows_proc/ # ๐ช windows + ๐ processes
โ โโโ files/ # ๐ + download
โ โโโ clipboard/ # โ
โ โโโ network/ # ๐ก / ๐ง / ๐ถ / ip
โ โโโ shell/ # cmd / ps1 / launch / url
โ โโโ media/ # ๐ฆ VLC + ๐ฌ Netflix
โ
โโโ data/ # persistent JSON state (atomic writes)
โ โโโ key_builder_state.json
โ โโโ macros.json
โโโ logs/ # rotating bot.log
โโโ intruders.json # log of unauthorized attempts
Each feature folder contains:
| File | Role |
|---|---|
service.py |
Pure logic. No Telegram imports. |
ui.py (optional) |
Inline keyboard builders for this feature. |
handlers.py |
Telegram glue. Exposes register(app) and match_text(text, chat_id) โ TextResult | None. |
__init__.py |
Re-exports register, match_text, and any helpers other features need (e.g. keys.send_combos is consumed by macros). |
Why FSD?
- Each feature is a plug-in โ adding or removing one means touching one folder and one line in
app/features/__init__.py. - No god-files: there is no central
handlers.pyorui.py. Inline keyboards live next to the logic that uses them. - The text dispatcher is a chain of responsibility โ
core/router.pywalksALL_FEATURESin order and asks eachmatch_text(text, chat_id). The first non-Nonereply wins. Heavy/stateful features (screenshot, recording, webcam, switcher) skip the chain and register their ownMessageHandlerso they can stream binary uploads. - Callbacks are namespaced per feature (
vlc:,nfx:,kb:,sw:,vol:,bright:,power:,net:) and routed viaCallbackQueryHandler(pattern=r"^ns:")โ no central callback dispatcher.
- Owner gate. Every handler is wrapped by
@owner_only(or its inline equivalent). Authorisation = (numericchat_idโ{OWNER_CHAT_ID} โช EXTRA_OWNER_CHAT_IDS) or (usernameโ{OWNER_USERNAME} โช EXTRA_OWNER_USERNAMES). - Multilingual intruder response. Strangers receive
๐จ Only the owner can use this bot. Your activity has been logged.translated into English, Hindi, Russian, Spanish, Chinese, Arabic, French, German, Portuguese, Japanese, Turkish, and Hebrew, plus a link back to this repo. - Intrusion log.
intruders.jsonaccumulates{user_id โ first_attempt, last_attempt, attempts, name, username}. Writes are atomic (temp file +os.replace) with a single rotating.bak. - Per-chat rate limit. A sliding 60-second window allows at most
RATE_LIMIT_PER_MINUTEmessages from any single chat (default 60). Excess getsโฑ Slow down โ rate limit hit.. - Forwarded evidence. When an unknown user without a username messages the bot, their original message is forwarded to the owner so it can be inspected.
โ ๏ธ Network exposure. This bot polls Telegram โ no incoming ports are opened on your PC. But anyone who learns yourBOT_TOKENcan impersonate the bot, so keep.envout of version control.
Build a one-file .exe (see next section), then register it to launch at user logon:
SCHTASKS /CREATE /SC ONLOGON `
/TN "Telegram-Windows-Command-Bot" `
/TR '"C:\path\to\Telegram windows command bot.exe"' `
/RL HIGHESTOr run the script form directly via a .bat shortcut placed in shell:startup.
.\venv\Scripts\Activate.ps1
pip install pyinstaller
pyinstaller --onefile -w -i "bot.png" `
--paths "venv\Lib\site-packages" `
main.py
# clean up
Move-Item .\dist\main.exe ".\Telegram windows command bot.exe" -Force
Remove-Item -Recurse -Force .\build, .\dist
Remove-Item .\main.specThe single .exe will still need .env and the data/ and logs/ folders next to it (they are created on first run).
ืืื ืืืืจื ืฉืฉืืื ืขื ืืืฉื Windows ืืจืืืง.
ืื ืื? ืฉืืืืื ืืืืขืืช ืืืื ืืืืืจื โ ืืืืืฉื ืืืฆืข ืืช ืืคืงืืืืช. ืฉืืืื ืืงืฉืื ืืืฉืื, ืฆืืืืื ืืกื, ื ืขืืื / ืฉืื ื / ืืืืื, ืฉืืืื ืึพVLC ืืื ืืคืืืงืก, ืงืจืืืช ืคืจืืฆืกืื, ืืืืฉื ืืงืืฆืื, ืืงืืืช ืืกื ืืขืื.
ืืคืืฆ'ืจ ืืืจืืื โ ืฉืืืืื ืืงืฉืื ืืืืฉืื
ืืคืฉืจ ืืฉืืื ืื ืงืืืืื ืฆืื: k ctrl+alt+del, k win+shift+s, k alt+f4. ืื ืื ืืืืจืื ืืช ืืชืืืืจ โ ืืืืฆืื ืขื โจ๏ธ Builder ืืืื ืื ืืช ืืงืืืืื ืฆืื ืืืืืฆืืช (ืืฉ Ctrl/Shift/Alt/Win ืืฉื ื ืืฆืืืื, ืืืื ืืฉืืื). ืืคืฉืจ ืื ืืฉืืืจ macros ืขื ืฉื:
/save_macro snip win+shift+s
/macro snip
ืืชื ืืืื ืืช ืืื ืืจืืงืืืื ๐
ืืคืชืืจ Switcher ืืืื ืืืืฆื ืืจืืื ืขื Alt+Tab โ ืืืื ืืืืืง ืืช Alt ืืืืฅ, ืืชื ืืืืฅ Tab+1 ืื Tab+5 ืืืืืจื, ืืงืื ืฆืืืื ืืกื ืืขืืืื ืฉื ืืชื ืืืืื ืืช, ืืืืืจ โ
Commit ืืืืืืฃ ืืืืื ืืืกืืื.
ืืงืื ืืืืจื
- ืืืจื ืืช ืืงืื ืืืจืืคื.
- ืฆืืจ ืกืืืื ืืืจืืืืืืช ืขื Python 3.12 ืืืชืงื ืืช
requirements.txt. - ืืืฆื ืืืงื ืืื ืึพ@BotFather, ืืฆื ืืช ืึพChat ID ืฉืื ืืฆื @userinfobot.
- ืืขืชืง ืืช
.env.exampleืึพ.envืืืืBOT_TOKEN,OWNER_CHAT_ID,OWNER_USERNAME. - ืืคืขื ืขื
python main.pyืืrun_bot.bat.
ืืืืื
ืจืง ืืืฉืชืืฉ ืฉืืืืืจ ืืงืืืฅ .env ืืืื ืืฉืืื ืคืงืืืืช. ืื ื ืืกืืื ืฉื ืืืฉืื ืืืจ ื ืจืฉื ืึพintruders.json ืืืืขืืจ ืืืื ืืืชืจืื. ืืืจืื ืืงืืืื ืชืืืื ืืืืื ืึพ12 ืฉืคืืช ืขื ืงืืฉืืจ ืืคืจืืืงื ืืคืชืื ืฉืื.
ืืคืขืื ืืืืืืืืช ืขื ืืืืงืช ืืืืฉื ืจืื ืืช ืืกืขืืฃ Auto-start on boot ืืืขืื.
Issues and pull requests welcome. The Feature-Sliced layout makes it easy to add a new feature:
mkdir app/features/<your_feature>/- Create
service.py,handlers.py, optionallyui.py, and an__init__.pythat re-exportsregisterandmatch_text. - Add the module to
app/features/__init__.pyand to theALL_FEATURESlist. - That's it โ your feature will be wired in automatically on next launch.
Please never commit .env, intruders.json, data/key_builder_state.json, or logs/.
This repository is currently published without an explicit license, which means all rights are reserved by default. If you want to use the code in your own project, open an issue and the maintainer will gladly discuss adding a permissive license (MIT is recommended for a project of this scope).
Built with โค๏ธ in Israel ยท powered by python-telegram-bot ยท pyautogui ยท pycaw ยท mss.


