模拟变轨滑块模拟人工拖动

import pyautogui
import random
#模拟移动变轨
def movePushCaptch(xPixel,yPixel):
    '''
    xPixel x轴需要移动的像素
    0,像素补偿
    minNum拖动随机最大值
    maxNum 拖动随机最小值
    '''
    minNum=0.005
    maxNum=0.05

    xPixel += 20 + 0
    v0 = 0
    a_list = [3, 4, 5]
    t = 0.2
    s = 0
    front = []
    back = [-1, -1, -2, -3, -2, -3, -2, -2, -3, -1]
    mid = xPixel * 3/ 5
    while s < xPixel:
        if s < mid:
            a = a_list[random.randint(0, 2)]
        else:
            a = -a_list[random.randint(0, 2)]
        v = v0
        stack = v * t + 0.5 * a * t ** 2
        stack = round(stack)
        s += stack
        v0 = v + a * t
        front.append(stack)

    pyautogui.PAUSE = 2
    pyautogui.PAUSE = 0.2
    pyautogui.mouseDown()
    pyautogui.PAUSE = 1
    for value in front:
        pyautogui.moveRel(value, 0)#0代表Y坐标偏移, 0为不偏移 向右拖动时候的偏移,正数向下,负数向上
        aa = random.uniform(minNum, maxNum)#鼠标拖动的随机数
        pyautogui.PAUSE = aa#鼠标拖动的速度

    # for value in back:
    #     pyautogui.moveRel(value, 0)#0代表Y坐标偏移, 0为不偏移 向右拖动时候的偏移,正数向下,负数向上
    #     bb=random.uniform(0.01, 0.01)#鼠标拖动返回的随机数
    #     pyautogui.PAUSE = bb#返回时候速度

    pyautogui.PAUSE = 1.2
    pyautogui.mouseUp()
    pyautogui.PAUSE = 0.3
movePushCaptch(300,3)


  目录