Python Forum
Mouse lib keeps dropping same error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mouse lib keeps dropping same error
#1
Hi. I have lost all my hopes fixing this issiue. Can anyone help?

import mouse
from tkinter import *
import time
import os

run = type(True)

def noclick():
    run = False
    exit()

def clicker():
    cap = float(e)
    while (run == True):
        mouse.click("left")
        time.sleep(cap)

mouse.on_double_click(lambda: exec(clicker()))
mouse.on_right_click(lambda: exec(noclick()))
print("Literaly a clicker for POPCAT")
print("Enter number (the less the faster it goes)")
print("Right click on mouse to turn the script off")
e = input("Time gaps between clicks: ")
print("Double click to activate")
Error:
mouse.on_double_click(lambda: exec(clicker())) TypeError: exec() arg 1 must be a string, bytes or code object
Reply
#2
Looks like it wants a function, not for you to call the function. So should probably be something like:

mouse.on_double_click(clicker)
mouse.on_right_click(noclick)
MLGpotato likes this post
Reply
#3
(Apr-13-2021, 03:46 PM)bowlofred Wrote: Looks like it wants a function, not for you to call the function. So should probably be something like:

mouse.on_double_click(clicker)
mouse.on_right_click(noclick)

Looks like it worked! Smile But I got another problem. It does not do the noclick function anymore. Doh
Reply
#4
What is the behavior when you try? It looks like it should stop the program via the exit(). Does that not happen?

Also, what is the purpose of this line?

run = type(True)
Setting a flag to True I could see, but what is the return value of type() for?
Reply
#5
(Apr-14-2021, 12:06 AM)bowlofred Wrote: What is the behavior when you try? It looks like it should stop the program via the exit(). Does that not happen?

Also, what is the purpose of this line?

run = type(True)
Setting a flag to True I could see, but what is the return value of type() for?
It wont close the app. You can press it as long as you like. It even does not run the line. Doh Is it a problem with
mouse.on_right_click(noclick)
?
Reply
#6
More likely a problem with while/sleep blocking noclick from running. Does the program exit if you right click before double clicking?
Reply
#7
(Apr-14-2021, 12:08 PM)deanhystad Wrote: More likely a problem with while/sleep blocking noclick from running. Does the program exit if you right click before double clicking?
Yes
Reply
#8
I've never used that module before. I can get information from it (mouse.hook() and mouse.get_position() both report fine), but I can't seem to trigger callbacks on mouse.click() and similar. Not sure if there's a problem with the code, if the documentation is incomplete, or if I'm just doing something wrong. But it does seem a little touchy.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Dropping rows with missing values NewBeie 2 2,325 Jul-27-2020, 06:29 AM
Last Post: NewBeie
  mouse 0.7.0 - mouse polling hate 125-1000hz penahuse 1 2,465 Dec-06-2019, 09:51 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020