init
This commit is contained in:
commit
cc40a422e6
131
.gitignore
vendored
Normal file
131
.gitignore
vendored
Normal file
@ -0,0 +1,131 @@
|
||||
#
|
||||
config/cert/
|
||||
test_modules/
|
||||
config/SSL/fullchain.pem
|
||||
config/SSL/privkey.pem
|
||||
logs/
|
||||
SECRET_KEY.key
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
pip-wheel-metadata/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# celery beat schedule file
|
||||
celerybeat-schedule
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
33
README.md
Normal file
33
README.md
Normal file
@ -0,0 +1,33 @@
|
||||
# magic_keyboard_player
|
||||
|
||||
---
|
||||
|
||||
## 💻 Требования
|
||||
|
||||
- Python **3.13.1**
|
||||
- Windows (рекомендуется для `.exe` сборки)
|
||||
- Установленные зависимости (`requirements.txt`)
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Режим разработки
|
||||
|
||||
```bash
|
||||
# Создание виртуального окружения
|
||||
python -m venv env
|
||||
|
||||
# Установка зависимостей
|
||||
.\env\Scripts\pip3.13.exe install -r .\requirements.txt
|
||||
|
||||
# Запуск
|
||||
.\env\Scripts\python.exe magic_keyboard.py
|
||||
```
|
||||
|
||||
## 📦 Сборка .EXE
|
||||
```bash
|
||||
# Сборка hide
|
||||
.\env\Scripts\pyinstaller --noconfirm --onefile --windowed magic_keyboard.py
|
||||
|
||||
# Сборка console
|
||||
.\.venv\Scripts\pyinstaller --noconfirm --onefile magic_keyboard.py
|
||||
```
|
||||
48
magic_keyboard.py
Normal file
48
magic_keyboard.py
Normal file
@ -0,0 +1,48 @@
|
||||
import keyboard
|
||||
import time
|
||||
import ctypes
|
||||
|
||||
DEBUG = False
|
||||
|
||||
# Функции для управления мультимедиа
|
||||
def play_pause():
|
||||
if DEBUG: print("[ДЕЙСТВИЕ] Воспроизведение/Пауза")
|
||||
send_vk_code(0xB3) # VK_MEDIA_PLAY_PAUSE
|
||||
|
||||
def next_track():
|
||||
if DEBUG: print("[ДЕЙСТВИЕ] Следующий трек")
|
||||
send_vk_code(0xB0) # VK_MEDIA_NEXT_TRACK
|
||||
|
||||
def prev_track():
|
||||
if DEBUG: print("[ДЕЙСТВИЕ] Предыдущий трек")
|
||||
send_vk_code(0xB1) # VK_MEDIA_PREV_TRACK
|
||||
|
||||
# Отправка виртуального кода клавиши в Windows
|
||||
def send_vk_code(code):
|
||||
ctypes.windll.user32.keybd_event(code, 0, 0, 0) # key down
|
||||
time.sleep(0.15)
|
||||
ctypes.windll.user32.keybd_event(code, 0, 2, 0) # key up
|
||||
|
||||
# Привязываем горячие клавиши
|
||||
# keyboard.add_hotkey('f7', prev_track)
|
||||
# keyboard.add_hotkey('f8', play_pause)
|
||||
# keyboard.add_hotkey('f9', next_track)
|
||||
|
||||
keyboard.add_hotkey('right windows+f7', prev_track)
|
||||
keyboard.add_hotkey('right windows+f8', play_pause)
|
||||
keyboard.add_hotkey('right windows+f9', next_track)
|
||||
|
||||
# Обработчик нажатий клавиш (для отладки)
|
||||
def on_key(event):
|
||||
print(f"[НАЖАТО] {event.name}")
|
||||
|
||||
if DEBUG: keyboard.on_press(on_key)
|
||||
|
||||
print("Скрипт запущен. Нажмите F7/F8/F9 для управления музыкой. Ctrl+C — выход.")
|
||||
|
||||
# Бесконечный цикл
|
||||
try:
|
||||
while True:
|
||||
time.sleep(1)
|
||||
except KeyboardInterrupt:
|
||||
print("Скрипт завершён.")
|
||||
38
magic_keyboard.spec
Normal file
38
magic_keyboard.spec
Normal file
@ -0,0 +1,38 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
|
||||
|
||||
a = Analysis(
|
||||
['magic_keyboard.py'],
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=[],
|
||||
hiddenimports=[],
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
noarchive=False,
|
||||
optimize=0,
|
||||
)
|
||||
pyz = PYZ(a.pure)
|
||||
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
a.binaries,
|
||||
a.datas,
|
||||
[],
|
||||
name='magic_keyboard',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
runtime_tmpdir=None,
|
||||
console=True,
|
||||
disable_windowed_traceback=False,
|
||||
argv_emulation=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
)
|
||||
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
keyboard==0.13.5
|
||||
pyinstaller==6.12.0
|
||||
Loading…
x
Reference in New Issue
Block a user