I want to make a click macro with pyautogui (desire)

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

I want to make a click macro with pyautogui (desire)
I want to make a click macro with pyautogui (outlook)
I want to make a game with Python
I want to make a blog editor with django admin
[Introduction] I want to make a Mastodon Bot with Python! 【Beginners】
I want to make matplotlib a dark theme
I want to write to a file with Python
I want to transition with a button in flask
I want to climb a mountain with reinforcement learning
I want to work with a robot in python.
I want to split a character string with hiragana
[Python] I want to make a nested list a tuple
I want to manually create a legend with matplotlib
I want to run a quantum computer with Python
I want to bind a local variable with lambda
[Mac] I want to make a simple HTTP server that runs CGI with Python
I want to use a virtual environment with jupyter notebook!
I want to install a package from requirements.txt with poetry
I want to do ○○ with Pandas
[Visualization] I want to draw a beautiful graph with Plotly
I want to debug with Python
I want to make input () a nice complement in python
[Python] I want to make a 3D scatter plot of the epicenter with Cartopy + Matplotlib!
I want to make a voice changer using Python and SPTK with reference to a famous site
[5th] I tried to make a certain authenticator-like tool with python
I want to use a wildcard that I want to shell with Python remove
[2nd] I tried to make a certain authenticator-like tool with python
[3rd] I tried to make a certain authenticator-like tool with python
I want to do a full text search with elasticsearch + python
I tried to make a periodical process with Selenium and Python
I tried to make a 2channel post notification application with Python
I want to make a parameter list from CloudFormation code (yaml)
I tried to make a todo application using bottle with python
[4th] I tried to make a certain authenticator-like tool with python
[1st] I tried to make a certain authenticator-like tool with python
I tried to make a strange quote for Jojo with LSTM
I tried to make a mechanism of exclusive control with Go
I want to detect objects with OpenCV
I want to print in a comprehension
I want to blog with Jupyter Notebook
I want to build a Python environment
I want to pip install with PythonAnywhere
I want to analyze logs with Python
I want to play with aws with python
I want to make an automation program!
I tried to make a Web API
Python: I tried to make a flat / flat_map just right with a generator
(Matplotlib) I want to draw a graph with a size specified in pixels
I came up with a way to make a 3D model from a photo.
I tried to make a calculator with Tkinter so I will write it
I tried to make "Sakurai-san" a LINE BOT with API Gateway + Lambda
I tried to make a traffic light-like with Raspberry Pi 4 (Python edition)
I tried to make a url shortening service serverless with AWS CDK
I want to make a web application using React and Python flask
I was addicted to trying Cython with PyCharm, so make a note
A memorandum to make WebDAV only with nginx
I want to easily create a Noise Model
I want to use MATLAB feval with python
I want to INSERT a DataFrame into MSSQL
I want to create a window in Python
I want to mock datetime.datetime.now () even with pytest!