Initial commit
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import subprocess
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
# Директория проекта и файл скрипта
|
||||
SCRIPT_DIR = Path(__file__).parent.resolve()
|
||||
SILENT_SCRIPT = SCRIPT_DIR / "silent_send.py"
|
||||
|
||||
# Папка для ярлыков (создаётся автоматически)
|
||||
LINK_DIR = SCRIPT_DIR / "link"
|
||||
LINK_DIR.mkdir(exist_ok=True)
|
||||
|
||||
# Ищем pythonw.exe в системе (автоматически найдёт ваш Python)
|
||||
PYTHONW = shutil.which("pythonw.exe")
|
||||
if not PYTHONW:
|
||||
PYTHONW = "pythonw.exe" # Фоллбэк, если python есть в PATH
|
||||
|
||||
# Команды: ключ = имя в JSON, значение = имя файла ярлыка
|
||||
commands = {
|
||||
"power-on": "01_ВКЛ", "power-off": "02_ВЫКЛ", "night-light": "03_Ночной",
|
||||
"day-light": "04_Дневной", "warm": "05_Тёплый", "cold": "06_Холодный",
|
||||
"light-up": "07_Ярче", "light-down": "08_Темнее", "rgb": "09_RGB",
|
||||
"mode": "10_Режим", "tusklo": "11_Тускло", "teplo": "12_Тепло"
|
||||
}
|
||||
|
||||
print(f"🔍 Исполнитель: {PYTHONW}")
|
||||
print(f"📂 Папка ярлыков: {LINK_DIR}\n")
|
||||
|
||||
for cmd, label in commands.items():
|
||||
lnk_path = LINK_DIR / f"{label}.lnk"
|
||||
|
||||
# ✅ ПРАВИЛЬНОЕ РАЗДЕЛЕНИЕ:
|
||||
target_path = PYTHONW
|
||||
arguments = f'"{SILENT_SCRIPT}" {cmd}'
|
||||
working_dir = str(SCRIPT_DIR)
|
||||
|
||||
# PowerShell скрипт создания ярлыка
|
||||
ps_script = f"""
|
||||
$WshShell = New-Object -ComObject WScript.Shell
|
||||
$Shortcut = $WshShell.CreateShortcut('{lnk_path}')
|
||||
$Shortcut.TargetPath = '{target_path}'
|
||||
$Shortcut.Arguments = '{arguments}'
|
||||
$Shortcut.WorkingDirectory = '{working_dir}'
|
||||
$Shortcut.Save()
|
||||
"""
|
||||
|
||||
try:
|
||||
subprocess.run(["powershell", "-NoProfile", "-Command", ps_script], capture_output=True, check=True)
|
||||
print(f"✅ Создан: {lnk_path.name}")
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"❌ Ошибка создания {lnk_path.name}: {e.stderr.decode('utf-8')}")
|
||||
|
||||
print(f"\n🎉 Все ярлыки успешно созданы в: {LINK_DIR}")
|
||||
print("💡 Теперь зайдите в Свойства каждого ярлыка → вкладка 'Ярлык' → поле 'Быстрый вызов' и назначите клавиши.")
|
||||
Reference in New Issue
Block a user