python安装打包模块
pip install nuitka
核心程序编译成exe
python -m nuitka --standalone tiktok_mouse_move.py
python滑块算法
# coding:utf-8
import sys
import pyautogui as pg
def get_track(distance):
"""
根据偏移量获取移动轨迹
:param distance: 偏移量
:return: 移动轨迹
"""
# 移动轨迹
track = []
# 当前位移
current = 0
# 减速阈值
mid = distance * 3 / 4
# 计算间隔
t = 1
# 初速度
v = 0
while current < distance:
if current < mid:
# 加速度为正 2
a = 2
else:
# 加速度为负 3
a = -3
a = 4 if current < mid / 2 else (5 if current < mid else -3)
# 初速度 v0
v0 = v
# 当前速度 v = v0 + at
v = v0 + a * t
move = v0 * t + 1 / 2 * a * t * t
# 当前位移
current += move
# 加入轨迹
track.append(round(move))
# print '轨迹 ', track
return track
def move_hk(x,y,data,_tracks):
move_distance = 0
for long in _tracks:
move_distance=move_distance+long
pg.moveTo(x + move_distance, y, 0.1)
move_distance=move_distance+2
pg.moveTo(x + move_distance, y, 0.081)
move_distance=move_distance-2
pg.moveTo(x + move_distance, y, 0.075)
def main():
#print("第一个传入的参数为:", sys.argv[1])
distance = sys.argv[1]
x = sys.argv[2]
y = sys.argv[3]
distance = int(distance)
x = float(x)
y = float(y)
#x - -----------> 822.0
#y - -----------> 688.5
_tracks = get_track(distance)
new_1 = _tracks[-1] - (sum(_tracks) - distance)
_tracks.pop()
_tracks.append(new_1)
# 四个节点合并一个节点记得 节点总和-3
get_1 = _tracks[-1]
get_2 = _tracks[-2]
get_3 = _tracks[-3]
get_4 = _tracks[-4]
get_two = get_1 + get_2 + get_3 + get_4 - 7
_tracks.pop()
_tracks.pop()
_tracks.pop()
_tracks.pop()
_tracks.append(get_two)
_tracks.append(3)
_tracks.append(4)
move_hk(x, y, distance, _tracks)
print(distance,x,y)
if __name__ == "__main__":
#python .\test_mouse_move.py 160 822.0 688.5
main()
python调用exe代码
假设生成的exe目录在tiktok_mouse_move
cur_path = os.path.abspath(os.path.dirname(__file__)) sys.path.append(cur_path) os.popen(cur_path + '\\' + 'tiktok_mouse_move' + '\\' + 'tiktok_mouse_move.exe {0} {1} {2}'.format(distance,x,y)).read()