Моя первая работа до этого вообще этим не занимался, не надо обсирать. Пользовался ChatGPT Суть такая на проекте GTAV RP есть деморган (так называемая тюрьма) его надо проходить. Есть два варианта швейка надо кликать цифры и токарка водить мышкой за кружочком. Когда я пытался компилировать файл через PyInstaller у меня не ищется изображение которые нужны для швейки. Дайте совет как сделать это всё в 1 exe файл Чтобы получилось типо такого (без автобега) import os import random import string import threading import tkinter import tkinter as tk from tkinter import messagebox, simpledialog import configparser import shutil from PIL import Image, ImageTk import cv2 import numpy as np import pygetwindow as gw import pyautogui import time import keyboard import winsound import requests tkinter.Tk().withdraw() # Задаем шрифт текста и размер в кортеже button_font = ('Bahnschrift', 13, 'bold') sound_file = 'sdsda.mp3' TEMP_DIR = os.getenv('TEMP') # Основное окно def center_window(window, width, height): screen_width = window.winfo_screenwidth() screen_height = window.winfo_screenheight() x = (screen_width // 2) - (width // 2) y = (screen_height // 2) - (height // 2) window.geometry(f"{width}x{height}+{x}+{y}") root = tk.Tk() root.title("Центрированное окно") root.overrideredirect(True) root.configure(bg="#121212") window_width = 500 window_height = 200 center_window(root, window_width, window_height) #изображения для швейки def download_photo_shweyka(): urls = { "1.png": "https://imgur.com/a/yVSCaIA", "2.png": "https://imgur.com/v49MqcP", "3.png": "https://imgur.com/cxYqhM5", "4.png": "https://imgur.com/7sc7Lnh", "5.png": "https://imgur.com/rcvCPZE", "6.png": "https://imgur.com/n7H5TTI", "7.png": "https://imgur.com/zGMKZDU", "8.png": "https://imgur.com/f3gUnii", "9.png": "https://imgur.com/mAtuBih", "10.png": "https://imgur.com/RaUx1VH", "11.png": "https://imgur.com/NVMJgok", "12.png": "https://imgur.com/JYHwQLE", "13.png": "https://imgur.com/MrDBujh", "14.png": "https://imgur.com/azxu8py", "15.png": "https://imgur.com/6MAzMH2", "16.png": "https://imgur.com/KfP12gT", "17.png": "https://imgur.com/hu1vUd2", "18.png": "https://imgur.com/hmsQdCx", "19.png": "https://imgur.com/r7neDs5", "20.png": "https://imgur.com/bTpyqxY" } for filename, url in urls.items(): filepath = os.path.join(TEMP_DIR, filename) response = requests.get(url) with open(filepath, 'wb') as file: file.write(response.content) def play_sound_after_delay(delay): time.sleep(delay) playsound(sound_file) def close_window(): root.destroy() def stop_script(): global running, timer_running running = False # Останавливаем скрипт timer_running = False print("Скрипт остановлен.") def exit_script(): stop_script() # Швейка def shweyka(): download_photo_shweyka() shveyka_Wleft = 784 shveyka_Hleft = 270 shveyka_Wright = 1134 shveyka_Hright = 820 image_names = [f"{i}.png" for i in range(1, 21)] clicked_positions = [] found_positions = [] running = False # Отслеживание состояния скрипта timer_running = False def is_position_near(click_position, existing_positions, tolerance=5): for pos in existing_positions: if abs(click_position[0] - pos[0]) < tolerance and abs(click_position[1] - pos[1]) < tolerance: return True return False running = True clicked_positions = [] # Сброс предыдущих позиций перед запуском time.sleep(1) # Задержка перед началом работы while running: screenshot = pyautogui.screenshot( region=(shveyka_Wleft, shveyka_Hleft, shveyka_Wright - shveyka_Wleft, shveyka_Hright - shveyka_Hleft)) screenshot = cv2.cvtColor(np.array(screenshot), cv2.COLOR_RGB2BGR) for image_name in image_names: small_img = cv2.imread(image_name) if small_img is None: print(f"Couldn't load image: {image_name}") continue res = cv2.matchTemplate(screenshot, small_img, cv2.TM_CCOEFF_NORMED) threshold = 0.9 loc = np.where(res >= threshold) if loc[0].size == 0: continue for pt in zip(*loc[::-1]): click_x = pt[0] + shveyka_Wleft + small_img.shape[1] // 2 click_y = pt[1] + shveyka_Hleft + small_img.shape[0] // 2 position = (click_x, click_y) if not is_position_near(position, clicked_positions): found_positions.append(position) clicked_positions.append(position) print(f"Found position: {position}") if image_name == '1.png': pyautogui.click(position[0], position[1]) time.sleep(0.5) else: pyautogui.click(position[0], position[1]) time.sleep(0.5) pyautogui.click(position[0], position[1]) time.sleep(0.5) found_positions.clear() time.sleep(1) def tokarka(): # Установите границы поиска tokarka_Wleft = 660 tokarka_Hleft = 679 tokarka_Wright = 1260 tokarka_Hright = 969 cnt = 0 max_attempts = 50 sleep_time = 0.2 # Загрузка шаблона один раз вне цикла template = cv2.imread('ZV.png', cv2.IMREAD_GRAYSCALE) if template is None: raise ValueError("Шаблон не найден. Проверьте путь к файлу 'ZV.png'.") while cnt <= max_attempts: try: # Скриншот ПК screenshot = pyautogui.screenshot( region=(tokarka_Wleft, tokarka_Hleft, tokarka_Wright - tokarka_Wleft, tokarka_Hright - tokarka_Hleft)) screenshot_np = np.array(screenshot) screenshot_gray = cv2.cvtColor(screenshot_np, cv2.COLOR_BGR2GRAY) # Поиск заточки result = cv2.matchTemplate(screenshot_gray, template, cv2.TM_CCOEFF_NORMED) threshold = 0.9 loc = np.where(result >= threshold) if loc[0].size > 0: for pt in zip(*loc[::-1]): xf, yf = pt yf += 62 pyautogui.moveTo(xf + tokarka_Wleft, yf + tokarka_Hleft, duration=0) break else: cnt += 1 time.sleep(sleep_time) except Exception as e: print(f"Ошибка: {e}") break def timer(seconds): for remaining in range(seconds, 0, -1): if not timer_running: break time.sleep(1) print(f"Осталось времени: {remaining} секунд") print("Таймер завершен.") def start_timer(): global timer_running timer_running = True threading.Thread(target=play_sound_after_delay, args=(83,)).start() print("Таймер запущен на 83 секунды.") #Клавиши запуска бота keyboard.add_hotkey('E', start_timer) # Запуск таймера при нажатии E keyboard.add_hotkey('F4', exit_script) keyboard.add_hotkey('F5', shweyka) keyboard.add_hotkey('F6', tokarka) # Окно бота №2 def menusettings(): settings_window = tk.Toplevel(root) settings_window.title("Настройки") settings_window.geometry("500x200") settings_window.overrideredirect(True) settings_window.configure(bg="#121212") settings_window.resizable(False, False) screen_width = settings_window.winfo_screenwidth() screen_height = settings_window.winfo_screenheight() window_width = 500 window_height = 200 x = (screen_width // 2) - (window_width // 2) y = (screen_height // 2) - (window_height // 2) settings_window.geometry(f"{window_width}x{window_height}+{x}+{y}") # Добавление текстовой надписи в окно настроек label = tk.Label(settings_window, text="Информация", bg="#121212", fg="white", font=('Bahnschrift', 13, 'bold')) label.place(x=180, y=10) # Кординаты кнопки # Добавление текстовой надписи в окно настроек label = tk.Label(settings_window, text="Швейка запускается на F5", bg="#121212", fg="white",font=('Bahnschrift', 11, 'bold')) label.place(x=10, y=40) # Кординаты кнопки # Добавление текстовой надписи в окно настроек label = tk.Label(settings_window, text="Токарка запускается на F6", bg="#121212", fg="white", font=('Bahnschrift', 11, 'bold')) label.place(x=10, y=60) # Кординаты кнопки # Добавление текстовой надписи в окно настроек label = tk.Label(settings_window, text="Перезапуск бота на F4", bg="#121212", fg="white", font=('Bahnschrift', 11, 'bold')) label.place(x=10, y=80) # Кординаты кнопки button = tk.Button(settings_window, text="Запуск", width=10, height=1, font=button_font, command=close_window) button.pack(pady=20) button.place(x=380, y=150) # Кнопки основного меню button = tk.Button(root, text="БОТ", width=15, height=2, font=button_font, command=menusettings) button.pack(pady=20) button.place(x=90, y=70) button = tk.Button(root, text="Помощь", width=15, height=2, font=button_font) button.pack(pady=20) button.place(x=270, y=70) root.mainloop() Python import os import random import string import threading import tkinter import tkinter as tk from tkinter import messagebox, simpledialog import configparser import shutil from PIL import Image, ImageTk import cv2 import numpy as np import pygetwindow as gw import pyautogui import time import keyboard import winsound import requests tkinter.Tk().withdraw() # Задаем шрифт текста и размер в кортеже button_font = ('Bahnschrift', 13, 'bold') sound_file = 'sdsda.mp3' TEMP_DIR = os.getenv('TEMP') # Основное окно def center_window(window, width, height): screen_width = window.winfo_screenwidth() screen_height = window.winfo_screenheight() x = (screen_width // 2) - (width // 2) y = (screen_height // 2) - (height // 2) window.geometry(f"{width}x{height}+{x}+{y}") root = tk.Tk() root.title("Центрированное окно") root.overrideredirect(True) root.configure(bg="#121212") window_width = 500 window_height = 200 center_window(root, window_width, window_height) #изображения для швейки def download_photo_shweyka(): urls = { "1.png": "https://imgur.com/a/yVSCaIA", "2.png": "https://imgur.com/v49MqcP", "3.png": "https://imgur.com/cxYqhM5", "4.png": "https://imgur.com/7sc7Lnh", "5.png": "https://imgur.com/rcvCPZE", "6.png": "https://imgur.com/n7H5TTI", "7.png": "https://imgur.com/zGMKZDU", "8.png": "https://imgur.com/f3gUnii", "9.png": "https://imgur.com/mAtuBih", "10.png": "https://imgur.com/RaUx1VH", "11.png": "https://imgur.com/NVMJgok", "12.png": "https://imgur.com/JYHwQLE", "13.png": "https://imgur.com/MrDBujh", "14.png": "https://imgur.com/azxu8py", "15.png": "https://imgur.com/6MAzMH2", "16.png": "https://imgur.com/KfP12gT", "17.png": "https://imgur.com/hu1vUd2", "18.png": "https://imgur.com/hmsQdCx", "19.png": "https://imgur.com/r7neDs5", "20.png": "https://imgur.com/bTpyqxY" } for filename, url in urls.items(): filepath = os.path.join(TEMP_DIR, filename) response = requests.get(url) with open(filepath, 'wb') as file: file.write(response.content) def play_sound_after_delay(delay): time.sleep(delay) playsound(sound_file) def close_window(): root.destroy() def stop_script(): global running, timer_running running = False # Останавливаем скрипт timer_running = False print("Скрипт остановлен.") def exit_script(): stop_script() # Швейка def shweyka(): download_photo_shweyka() shveyka_Wleft = 784 shveyka_Hleft = 270 shveyka_Wright = 1134 shveyka_Hright = 820 image_names = [f"{i}.png" for i in range(1, 21)] clicked_positions = [] found_positions = [] running = False # Отслеживание состояния скрипта timer_running = False def is_position_near(click_position, existing_positions, tolerance=5): for pos in existing_positions: if abs(click_position[0] - pos[0]) < tolerance and abs(click_position[1] - pos[1]) < tolerance: return True return False running = True clicked_positions = [] # Сброс предыдущих позиций перед запуском time.sleep(1) # Задержка перед началом работы while running: screenshot = pyautogui.screenshot( region=(shveyka_Wleft, shveyka_Hleft, shveyka_Wright - shveyka_Wleft, shveyka_Hright - shveyka_Hleft)) screenshot = cv2.cvtColor(np.array(screenshot), cv2.COLOR_RGB2BGR) for image_name in image_names: small_img = cv2.imread(image_name) if small_img is None: print(f"Couldn't load image: {image_name}") continue res = cv2.matchTemplate(screenshot, small_img, cv2.TM_CCOEFF_NORMED) threshold = 0.9 loc = np.where(res >= threshold) if loc[0].size == 0: continue for pt in zip(*loc[::-1]): click_x = pt[0] + shveyka_Wleft + small_img.shape[1] // 2 click_y = pt[1] + shveyka_Hleft + small_img.shape[0] // 2 position = (click_x, click_y) if not is_position_near(position, clicked_positions): found_positions.append(position) clicked_positions.append(position) print(f"Found position: {position}") if image_name == '1.png': pyautogui.click(position[0], position[1]) time.sleep(0.5) else: pyautogui.click(position[0], position[1]) time.sleep(0.5) pyautogui.click(position[0], position[1]) time.sleep(0.5) found_positions.clear() time.sleep(1) def tokarka(): # Установите границы поиска tokarka_Wleft = 660 tokarka_Hleft = 679 tokarka_Wright = 1260 tokarka_Hright = 969 cnt = 0 max_attempts = 50 sleep_time = 0.2 # Загрузка шаблона один раз вне цикла template = cv2.imread('ZV.png', cv2.IMREAD_GRAYSCALE) if template is None: raise ValueError("Шаблон не найден. Проверьте путь к файлу 'ZV.png'.") while cnt <= max_attempts: try: # Скриншот ПК screenshot = pyautogui.screenshot( region=(tokarka_Wleft, tokarka_Hleft, tokarka_Wright - tokarka_Wleft, tokarka_Hright - tokarka_Hleft)) screenshot_np = np.array(screenshot) screenshot_gray = cv2.cvtColor(screenshot_np, cv2.COLOR_BGR2GRAY) # Поиск заточки result = cv2.matchTemplate(screenshot_gray, template, cv2.TM_CCOEFF_NORMED) threshold = 0.9 loc = np.where(result >= threshold) if loc[0].size > 0: for pt in zip(*loc[::-1]): xf, yf = pt yf += 62 pyautogui.moveTo(xf + tokarka_Wleft, yf + tokarka_Hleft, duration=0) break else: cnt += 1 time.sleep(sleep_time) except Exception as e: print(f"Ошибка: {e}") break def timer(seconds): for remaining in range(seconds, 0, -1): if not timer_running: break time.sleep(1) print(f"Осталось времени: {remaining} секунд") print("Таймер завершен.") def start_timer(): global timer_running timer_running = True threading.Thread(target=play_sound_after_delay, args=(83,)).start() print("Таймер запущен на 83 секунды.") #Клавиши запуска бота keyboard.add_hotkey('E', start_timer) # Запуск таймера при нажатии E keyboard.add_hotkey('F4', exit_script) keyboard.add_hotkey('F5', shweyka) keyboard.add_hotkey('F6', tokarka) # Окно бота №2 def menusettings(): settings_window = tk.Toplevel(root) settings_window.title("Настройки") settings_window.geometry("500x200") settings_window.overrideredirect(True) settings_window.configure(bg="#121212") settings_window.resizable(False, False) screen_width = settings_window.winfo_screenwidth() screen_height = settings_window.winfo_screenheight() window_width = 500 window_height = 200 x = (screen_width // 2) - (window_width // 2) y = (screen_height // 2) - (window_height // 2) settings_window.geometry(f"{window_width}x{window_height}+{x}+{y}") # Добавление текстовой надписи в окно настроек label = tk.Label(settings_window, text="Информация", bg="#121212", fg="white", font=('Bahnschrift', 13, 'bold')) label.place(x=180, y=10) # Кординаты кнопки # Добавление текстовой надписи в окно настроек label = tk.Label(settings_window, text="Швейка запускается на F5", bg="#121212", fg="white",font=('Bahnschrift', 11, 'bold')) label.place(x=10, y=40) # Кординаты кнопки # Добавление текстовой надписи в окно настроек label = tk.Label(settings_window, text="Токарка запускается на F6", bg="#121212", fg="white", font=('Bahnschrift', 11, 'bold')) label.place(x=10, y=60) # Кординаты кнопки # Добавление текстовой надписи в окно настроек label = tk.Label(settings_window, text="Перезапуск бота на F4", bg="#121212", fg="white", font=('Bahnschrift', 11, 'bold')) label.place(x=10, y=80) # Кординаты кнопки button = tk.Button(settings_window, text="Запуск", width=10, height=1, font=button_font, command=close_window) button.pack(pady=20) button.place(x=380, y=150) # Кнопки основного меню button = tk.Button(root, text="БОТ", width=15, height=2, font=button_font, command=menusettings) button.pack(pady=20) button.place(x=90, y=70) button = tk.Button(root, text="Помощь", width=15, height=2, font=button_font) button.pack(pady=20) button.place(x=270, y=70) root.mainloop()