So I have been working on a very basic 'fastclick macro'. I want the program to click more if I click faster than around 5 clicks per second. When it reaches the limit of 5 clicks per second, i want it to click in between your last and your next click, done with the time.sleep(clicktime / 2)
. For some reason, i get an error:
an integer is required (got type NoneType)
here is my code:
import pythoncom, pyHook, sys, winsound, os
import win32api, win32con, random, time
from pyHook import HookManager
from pyHook.HookManager import HookConstants
macro = False
tip = 1
firstclick = 0
secondclick = 0
clicktime = 1
bot = False
def ExtraClick():
global clicktime
global bot
x, y = win32api.GetCursorPos()
print('click')
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
bot = True
def OnMouseClick(event):
global tip
global firstclick
global secondclick
global clicktime
global macro
global bot
if bot == True:
bot = False
if bot == False:
if tip == 0:
tip = 1
firstclick = time.time()
clicktime = firstclick - secondclick
print(clicktime)
elif tip == 1:
tip = 0
secondclick = time.time()
clicktime = secondclick - firstclick
print(clicktime)
def OnKeyEvent(event):
global macro
if event.KeyID == 192:
if macro == True:
macro = False
print('off')
winsound.Beep(600, 30)
winsound.Beep(550, 30)
else:
macro = True
print('on')
winsound.Beep(1000, 30)
winsound.Beep(1100, 30)
clickspeed = 1
hm = pyHook.HookManager()
while True:
hm.MouseLeftDown = OnMouseClick
hm.KeyDown = OnKeyEvent
if clicktime < 0.20 and macro == True:
time.sleep(clicktime / 2)
ExtraClick()
hm.HookMouse()
hm.HookKeyboard()
pythoncom.PumpWaitingMessages()
i also tried to, instead of using time.sleep(clicktime / 2)
, time.sleep(0.1)
, but that gave the same error.