程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Using Python to automatically like friends

編輯:Python

Use this program only to familiarize yourself with pyautogui Application of modules , Not all the circles should be praised , Please use with caution !

We need to pyautogui modular ,pyautogui It's pure. Python Of GUI Automation tools , It allows the program to automatically control the mouse and keyboard .

1、 install  

pip3 install pyautogui

After installation, it can be used

2、 How to find the icon of the circle of friends on the screen

First take a screenshot of the circle of friends icon , Name it ( Circle of friends .png),pyautogui Use the function to match on the screen , Until we find an icon that is the same as our target icon , And you get the result .

#  Image recognition ( One )
oneicon = pyautogui.locateOnScreen(' Circle of friends .png')

Identify the result of an icon

  Identify two points

#  Image recognition ( Multiple )
multicon = pyautogui.locateAllOnScreen(' Two points .png')

After two points are identified, a result similar to the following is returned ( A list of ):

[Box(left=985, top=344, width=79, height=49), Box(left=985, top=1322, width=79, height=49)]

This is it. “ Two points ”( On the screenshot are two ) On the desktop , If you can't find the picture , It will return None.

Find the location of the picture and click , Just ok 了 .

pyautogui.click( Location )

3、 Program

import pyautogui
import time
top = 0 # The value that the screen scrolls up , It can be adjusted according to your own screen
covertop = 500 # The height of the cover of the circle of friends
delay = 0.01
# Looking for pictures
def findimge(image):
time.sleep(delay) # Time delay
if pyautogui.locateOnScreen(image):
left, top, width, height = pyautogui.locateOnScreen(image)
point = pyautogui.center((left, top, width, height))
pyautogui.click(point)
# Find the position of two points Roll one top value
def findtwopoint():
global top
time.sleep(delay)
if pyautogui.locateOnScreen(' Two points .png'):
left, top, width, height = pyautogui.locateOnScreen(' Two points .png')
point = pyautogui.center((left, top, width, height))
pyautogui.click(point)
def scrool():
global top
global covertop
time.sleep(delay)
if covertop == 0:
pyautogui.scroll(int(-top / 2)) # Scroll the mouse wheel
else:
pyautogui.scroll(-top + covertop)
covertop = 0
if __name__ == "__main__":
findimge(' Circle of friends .png')
while True:
findtwopoint()
findimge(' Fabulous .png')
scrool()

4、 function :

Open the computer version of wechat , window maximizing

Run the program

The problem is : Like it , If you click again on the current screen , If you can detect that you have clicked , Just roll over ok 了 .


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved