As a completely personal note: yum:
The code I wrote this time is below
jidou.py
#!/usr/bin/python
import pyautogui as pg
import time as ti
import random as rm
def syutuxy():
x,y=pg.locateCenterOnScreen("syutu.png ")
rx=rm.randint(-39,21)
ry=rm.randint(-39,26)
x=x+rx
y=y+ry
return x,y
ti.sleep(1)
pg.PAUSE=1.0
x,y=syutuxy()
if x != None and y != None:
pg.click(x,y,button="left",duration=0.5)
else:
print("nooo")
It will search for coordinates that match the image prepared in advance.
This time, the coordinates are extracted including random elements.
For the time being, I was able to confirm the operation of the library.
The image to prepare should be prepared by "shift + command + 4" of mac.
Random elements are different for each button, so make sure to take a screenshot so that you can get the original center.
→ After that, specify a random range ...
Next time, I wonder if I will layer the image folders and generate each button image: zzz:
Recommended Posts