SavinaRoja / PyUserInput

A module for cross-platform control of the mouse and keyboard in python that is simple to install and use.
GNU General Public License v3.0
1.07k stars 244 forks source link

Mouse click does not activate other windows #94

Open sajja opened 7 years ago

sajja commented 7 years ago

Trying to listen to mouse event ,if clicked I'm trying to move the mouse to different location and emit another mouse event. it does not seem to work. Mouse correctly moves to specified location. But click event does not bring up the background window to foreground.

My code as follows


from pymouse import PyMouseEvent
from pymouse import PyMouse
from pykeyboard import PyKeyboard
from pykeyboard import PyKeyboardEvent

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

    def click( self, x, y, button, press):
        m = PyMouse()   
        if button == 2:
            if press:
                print x,y
                m.move(1283,515)
                m.click(1283,515,1)
            else:
                print "other"

C = Clickonacci()
C.run()

Environment

Linux/Ubuntu Python 2.7.6

Thanks. Sajith