import win32gui import pyautogui def get_pixel_colour(i_x = 1051, i_y = 903): i_desktop_window_id = win32gui.GetDesktopWindow() i_desktop_window_dc = win32gui.GetWindowDC(i_desktop_window_id) long_colour = win32gui.GetPixel(i_desktop_window_dc, i_x, i_y) i_colour = int(long_colour) return (i_colour & 0xff), ((i_colour >> 8) & 0xff), ((i_colour >> 16) & 0xff) def inventory(i_x = 1575, i_y = 439): i_desktop_window_id = win32gui.GetDesktopWindow() i_desktop_window_dc = win32gui.GetWindowDC(i_desktop_window_id) long_colour = win32gui.GetPixel(i_desktop_window_dc, i_x, i_y) i_colour = int(long_colour) return (i_colour & 0xff), ((i_colour >> 8) & 0xff), ((i_colour >> 16) & 0xff) def check(i_x = 784, i_y = 1069): i_desktop_window_id = win32gui.GetDesktopWindow() i_desktop_window_dc = win32gui.GetWindowDC(i_desktop_window_id) long_colour = win32gui.GetPixel(i_desktop_window_dc, i_x, i_y) i_colour = int(long_colour) return (i_colour & 0xff), ((i_colour >> 8) & 0xff), ((i_colour >> 16) & 0xff) def check_inventory(): if inventory() == (253, 94, 26): pyautogui.press('i') pyautogui.click(550, 414, clicks=3, interval=0.3) pyautogui.click(550, 532, clicks=3, interval=0.3) def fishing(): if get_pixel_colour() == (254, 0, 0): pyautogui.click(550, 414, clicks=3, interval=0.1) pyautogui.click(750, 414, clicks=3, interval=0.1) def main(): while check() == (100, 234, 43): if inventory() == (253, 94, 26): check_inventory() else: pass if get_pixel_colour() == (254, 0, 0): fishing() else: pass
На псевдокоде моя программа должна выглядить вот так -
Если значение инвентаря не равно (253,94,26)
то нажимается клавиша i И 6 кликов
Потом если get_pixel_colour равен == 254,0,0
то посылаем шесть кликов
Потом если чек равен (100,234,43)
ТО возвращается к проверке инвентаря
Иначе возвращается к get_pixel_colour
как мне сделать скрипт который я написал на ахк , переписать на питоне
Label10: BlockInput, SendAndMouse SendInput, {sc17} Label20: MouseGetPos, 1242, 420 PixelGetColor, color, 1242, 420, alt Var40 = %color% if ( var40 = 0xFFFFFF ) { Random, rand10, 200, 600 sleep 500+rand10 MouseGetPos, 1580, 440 PixelGetColor, color, 1580, 440, alt Var10 = %color% if ( var10 = 0x2A68FC ) | ( var10 = 0x1C5FFC ) | ( var10 = 0x1C60FC ) | ( var10 = 0x1C61FC ) { SoundBeep, 750, 500 SendInput, {Numpad3} BlockInput, Default } else { Click Left 550,394 , Random, rand20, 50, 100 sleep, 200+rand20 Click Left 550, 520, BlockInput, Default sleep, 5000 PixelGetColor, answer, 812, 492 if ( answer = 0xFFFFFF) { SoundBeep, 750, 500 sleep, 1000 } Label30: MouseGetPos, 1051, 898 PixelGetColor, color, 1051, 898, alt Var20 = %color% if ( var20 = 0x0000FF ) { Random, rand3, 5, 10 Send {Click} sleep 70+rand3 Send {Click} sleep 70+rand3 Send {Click} sleep 70+rand3 Send {Click} sleep 40+rand3 Goto, Label30 } else { MouseGetPos, 624, 1024 PixelGetColor, color, 624, 1024, alt Var30 = %color% if ( var30 = 0x00FF4E ) { Goto, Label10 } else { Goto, Label30 } } } } else { Goto, Label20 }