Skip to content

Pymouse / PyMouseEvent .run() doesn't resume function after .stop() is called #117

@joaomamede

Description

@joaomamede

This is a linux machine.
This was working 3/4 years ago when I wrote it and now it's buggy.

from pymouse import PyMouse
from pymouse import PyMouseEvent
from pykeyboard import PyKeyboard
import pyperclip
import numpy as np
m = PyMouse()
k = PyKeyboard()



class set_position(PyMouseEvent):
    def __init__(self):
        PyMouseEvent.__init__(self)

    def click(self,x,y,button,press):
        if button == 1:
            if press:
               self.value = m.position()
               print self.value
        else:
            print "aborted"
            self.stop()

Then in my main program:

This is how it was and it was running fine in previous versions.

    print "Please Click on a section without text"
    scan_button = set_position()
    scan_button.run()
    scan_x, scan_y = scan_button.value

When I clicked with button 1 it would set the value, correctly and when I clicked middle or button 2, it would resume the python script or, go back to prompt.

Now it gets stuck.
if I put prints on the "if button ==1" then and else. It does capture mouse events until I press any other button. But then it gets stuck until ctrl+c is pressed many many times.

if I switch to

    print "Please Click on a section without text"
    scan_button = set_position()
    scan_button.start()
    scan_x, scan_y = scan_button.value

It comes back to the python shell but value was never defined because it runs in the background and proceeds right away.

Am I doing something wrong that doesn't match most recent versions? Thanks

The example with clickonacci has the exact same problem, anything I can do?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions