循环点击脚本

win10点击脚本一般可以用python或者autohotkey写出来

有的游戏虽然有电脑端,但是自带检测功能,即使用管理员权限运行脚本,依然可以被中途停止

目前有一种方法是用安卓模拟器,如nox运行游戏,然后执行python点击脚本,进入脚本test.py所在目录打开cmd或者powershell,然后直接输入python test.py,背景窗口为最大化的模拟器

下面给一段python点击脚本的实测程序,会循环识别截图,然后点击

from PIL import ImageGrab

import cv2

import numpy as np

import pyautogui

import time

def capture_screen():

    screenshot = ImageGrab.grab()

    screenshot_cv = cv2.cvtColor(np.array(screenshot), cv2.COLOR_RGB2BGR)

    return screenshot_cv

#将脚本目录下的图片和截图对比

def detect_template(image, template_path, threshold=0.8):

    template = cv2.imread(template_path, cv2.IMREAD_GRAYSCALE)

    image_gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

    w, h = template.shape[::-1]

    res = cv2.matchTemplate(image_gray, template, cv2.TM_CCOEFF_NORMED)

    min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)

    if max_val >= threshold:

        top_left = max_loc

        bottom_right = (top_left[0] + w, top_left[1] + h)

        return True, top_left, bottom_right

    return False, None, None

def click_point(x, y):

    pyautogui.click(x, y)

    

# 向右滑动

def swipe_right(x, y):

    pyautogui.moveTo(x, y)

    pyautogui.dragRel(200, 0, duration=0.8)  

# 向左滑动

def swipe_left(x, y):

    pyautogui.moveTo(x, y)

    pyautogui.dragRel(-200, 0, duration=0.8)

# 长按

def long_press(x, y, duration=3):

    pyautogui.mouseDown(x, y)

    time.sleep(duration)

    pyautogui.mouseUp(x, y)

# 将脚本目录下的图片和截图对比,相符合点击对应的点

def perform_action(image, template_path, click_position, wait_time, threshold=0.8):

    found, top_left, bottom_right = detect_template(image, template_path, threshold)

    if found:

        click_point(*click_position)

        time.sleep(wait_time)

    return found

def main():

    while True:

        screen = capture_screen()

        #开始

        if perform_action(screen, '1.png', (100,200), 1):

            continue

        if perform_action(screen, '2.png', (300, 400), 1):

            continue

        #循环操作

        while detect_template(screen, '4.png')[0]:

            screen = capture_screen()

            if detect_template(screen, '4.png')[0]:

                time.sleep(2)

                long_press(500,600, 3)

                click_point(700, 800)

                click_point(900, 1000)

                swipe_right(1027, 527)

                time.sleep(1)                    

        # 退出

        if perform_action(screen, '6.png', (381, 892), 1):

            continue

        # 可能出现一个或多个

        if detect_template(screen, '9.png')[0]:

            click_point(1637, 927)

            time.sleep(1)

            continue

        elif detect_template(screen, '10.png')[0]:

            click_point(1513, 21)

            time.sleep(2)

            continue

if __name__ == "__main__":

    main()

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值