如何每秒执行一次函数X次?

时间:2020-08-13 17:41:18

标签: python math sleep pynput cps

我正在编写一个自动答题器,并希望将延迟作为CPS(每秒的点击数),那么,如何从python中的CPS值计算出延迟?

我尝试使用谷歌搜索,但只找到了CPS测试人员,没有实际代码

这是一段代码:

def clickerstart():  #this functions activates when you press the "start" button in the autocklicker menu  ¦
    if clickerlmb == 1:
        mouse.press(Button.left)
        time.sleep(delay) # "delay" is the time to sleep, found from the CPS
        mouse.release(Button.left)

1 个答案:

答案 0 :(得分:1)

期间= 1 /频率

您正在将每秒的点击次数转换为每次点击的秒数。根据您可能的变量:

delay = 1 / cps