import time import pyautogui import win32gui import win32con import ctypes def…
- User
import time import pyautogui import win32gui import win32con import ctypes def click_on_screen(x, y): pyautogui.moveTo(x, y) time.sleep(0.2) pyautogui.click(x, y)
def send_command(command): hwnd = win32gui.FindWindow(None, selected_window) win32gui.SetForegroundWindow(hwnd) time.sleep(0.2) # Poczekaj na aktywację okna pyautogui.press('/') pyautogui.typewrite(f"{command}") pyautogui.press('enter')
def get_window_list(): def callback(hwnd, hwnd_list): if win32gui.IsWindowVisible(hwnd) and win32gui.GetWindowText(hwnd) != '': hwnd_list.append((hwnd, win32gui.GetWindowText(hwnd))) return True
hwnd_list = [] win32gui.EnumWindows(callback, hwnd_list) return hwnd_listjedz_pol = (1031, 460) marchew = (1069, 395) kup_marchew = (1073,438) kup_marchew2 = (1002,487) ziemniak = (1031,396) kup_ziemniak = (1073,438) kup_ziemniak2 = (1002,487) pszenica = (851,432) kup_pszenica = (1073,438) kup_pszenica2 = (956,452) kup_monety = (924,505)
window_list = get_window_list()
Wybierz okno Minecraft
print("Dostępne okna:") for i, (hwnd, window_title) in enumerate(window_list): print(f"{i+1}. {window_title}") selected_index = int(input("Wybierz numer okna: ")) - 1 selected_window = window_list[selected_index][1]
while True: hwnd = win32gui.FindWindow(None, selected_window) if hwnd != 0: # Minecraft jest uruchomiony start_time = time.time() send_command('sklep') time.sleep(1) # Poczekaj na wysłanie komendy
click_on_screen(*jedz_pol) time.sleep(1) # Poczekaj na kliknięcie click_on_screen(*marchew) time.sleep(1) # Poczekaj na kliknięcie click_on_screen(*kup_marchew) time.sleep(1) # Poczekaj na kliknięcie click_on_screen(*kup_marchew2) time.sleep(1) # Poczekaj na kliknięcie click_on_screen(*ziemniak) time.sleep(1) # Poczekaj na kliknięcie click_on_screen(*kup_ziemniak) time.sleep(1) # Poczekaj na kliknięcie click_on_screen(*kup_ziemniak2) time.sleep(1) # Poczekaj na kliknięcie click_on_screen(*pszenica) time.sleep(1) # Poczekaj na kliknięcie click_on_screen(*kup_pszenica) time.sleep(1) # Poczekaj na kliknięcie click_on_screen(*kup_pszenica2) time.sleep(1) # Poczekaj na kliknięcie pyautogui.press('escape') send_command('farmer') time.sleep(1) # Poczekaj na wysłanie komendy click_on_screen(*kup_monety) time.sleep(1) # Poczekaj na kliknięcie click_on_screen(*kup_monety) time.sleep(1) # Poczekaj na kliknięcie click_on_screen(*kup_monety) time.sleep(1) # Poczekaj na kliknięcie click_on_screen(*kup_monety) time.sleep(1) # Poczekaj na kliknięcie pyautogui.press('escape') end_time = time.time() execution_time = end_time - start_time print(f"Czas stworzenia monety: {execution_time}") else: # Minecraft nie jest uruchomiony print("Okno Minecraft zostało zamknięte.") print("Dostępne okna:") for i, (hwnd, window_title) in enumerate(window_list): print(f"{i+1}. {window_title}") selected_index = int(input("Wybierz numer okna: ")) - 1 selected_window = window_list[selected_index][1] - Assistant
Unfortunately, I cannot directly convert this Python code to AutoHotkey due to the significant differences between Python and AutoHotkey. However, I can guide you on how to create a similar script in AutoHotkey that would perform the same tasks as your current Python code.
-
Install AutoHotkey: If you haven't already, download and install AutoHotkey from the official website (https://www.autohotkey.com/).
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.