1
# -*- coding: iso-8859-1 -*-
3
# Copyright 2010 Pepijn de Vos
5
# Licensed under the Apache License, Version 2.0 (the "License");
6
# you may not use this file except in compliance with the License.
7
# You may obtain a copy of the License at
9
# http://www.apache.org/licenses/LICENSE-2.0
11
# Unless required by applicable law or agreed to in writing, software
12
# distributed under the License is distributed on an "AS IS" BASIS,
13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
# See the License for the specific language governing permissions and
15
# limitations under the License.
17
"""The goal of PyMouse is to have a cross-platform way to control the mouse.
18
PyMouse should work on Windows, Mac and any Unix that has xlib.
20
See http://github.com/pepijndevos/PyMouse for more information.
23
from threading import Thread
25
class PyMouseMeta(object):
27
def press(self, x, y, button = 1):
28
"""Press the mouse on a givven x, y and button.
29
Button is defined as 1 = left, 2 = right, 3 = middle."""
31
raise NotImplementedError
33
def release(self, x, y, button = 1):
34
"""Release the mouse on a givven x, y and button.
35
Button is defined as 1 = left, 2 = right, 3 = middle."""
37
raise NotImplementedError
39
def click(self, x, y, button = 1):
40
"""Click the mouse on a givven x, y and button.
41
Button is defined as 1 = left, 2 = right, 3 = middle."""
43
self.press(x, y, button)
44
self.release(x, y, button)
47
"""Move the mouse to a givven x and y"""
49
raise NotImplementedError
52
"""Get the current mouse position in pixels.
53
Returns a tuple of 2 integers"""
55
raise NotImplementedError
57
def screen_size(self):
58
"""Get the current screen size in pixels.
59
Returns a tuple of 2 integers"""
61
raise NotImplementedError
63
class PyMouseEventMeta(Thread):
65
def __init__(self, capture=False):
68
self.capture = capture
74
def click(self, x, y, button, press):
75
"""Subclass this method with your click event handler"""
80
"""Subclass this method with your move event handler"""