Python PyAutoGUI | Automation in Grand Theft Auto minigame

Viewed 48

So I've got this "minigame" where I should click "space" when the blue line hits the green line. My first problem is that the circle is transparent, and therefore not a constant color. My second problem is that in Grand Theft Auto the sun moves, and therefor the background is also never a constant color.

Minigame Pic

Short Video of the minigame..

https://youtu.be/q2pjj7weZkQ

This is what I've tried

from pyautogui import *
import pyautogui
import time
import keyboard
import random
import win32api, win32con

time.sleep(3)


def click(x,y):
     win32api.SetCursorPos((x,y))
     win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
     time.sleep(0.01)
     win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)

while keyboard.is_pressed('h') == False:

# count = 0

     pic = pyautogui.screenshot(region=(900,700,115,115))

     width, height = pic.size

     #keyboard.press("e")
     #time.sleep(0.1)
     #keyboard.release("e")
     #time.sleep(1)

     #while count <= 4:
          for x in range(0,width,5):
               for y in range(0,height,5):

                    r,g,b = pic.getpixel((x,y))

                    if (g in range(152,155)):
                        if (b in range(186,189)):
                           if (r in range(56,59)):
                                keyboard.press("space")
                                time.sleep(0.05)
                                keyboard.release("space")
                                time.sleep(1)
                                #count = count + 1
                                break
0 Answers
Related