Skip to content

Commit

Permalink
Merge pull request #124 from glitchassassin/develop
Browse files Browse the repository at this point in the history
v0.7.2
  • Loading branch information
glitchassassin authored Jun 7, 2018
2 parents 2a6f313 + a0697bc commit 887807e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lackey/Geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def getColor(self):
if scr is None:
return None
offset = scr.getTopLeft().getOffset(self)
return self.getScreen().getBitmap()[offset.x, offset.y]
return self.getScreen().getBitmap()[offset.y, offset.x]
def getOffset(self, loc):
""" Returns the offset between the given point and this point """
return Location(loc.x - self.x, loc.y - self.y)
Expand Down
2 changes: 1 addition & 1 deletion lackey/InputEmulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ def click(self, loc=None, button=mouse.LEFT):
Use button constants Mouse.LEFT, Mouse.MIDDLE, Mouse.RIGHT
"""
self._lock.acquire()
if loc is not None:
self.moveSpeed(loc)
self._lock.acquire()
mouse.click(button)
self._lock.release()
def buttonDown(self, button=mouse.LEFT):
Expand Down
8 changes: 5 additions & 3 deletions lackey/PlatformManagerDarwin.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,13 @@ def _getVirtualScreenBitmap(self):
min_x, min_y, screen_w, screen_h = self._getVirtualScreenRect()
virtual_screen = Image.new("RGB", (screen_w, screen_h))
for filename, screen in zip(filenames, screen_details):
im = Image.open(filename)
im.load()
im = im.resize((int(im.size[0]/2), int(im.size[1]/2)), Image.ANTIALIAS)
# Capture virtscreen coordinates of monitor
x, y, w, h = screen["rect"]
# Convert image size if needed
im = Image.open(filename)
im.load()
if im.size[0] != w or im.size[1] != h:
im = im.resize((int(w), int(h)), Image.ANTIALIAS)
# Convert to image-local coordinates
x = x - min_x
y = y - min_y
Expand Down
4 changes: 2 additions & 2 deletions lackey/PlatformManagerWindows.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ def getWindowByPID(self, pid, order=0):
ctypes.py_object)
def callback(hwnd, context):
if ctypes.windll.user32.IsWindowVisible(hwnd):
pid = ctypes.c_long()
pid = ctypes.c_ulong()
ctypes.windll.user32.GetWindowThreadProcessId(hwnd, ctypes.byref(pid))
if context["pid"] == int(pid.value) and not context["handle"]:
if context["order"] > 0:
Expand Down Expand Up @@ -569,7 +569,7 @@ def getWindowTitle(self, hwnd):
return buff.value
def getWindowPID(self, hwnd):
""" Gets the process ID that the specified window belongs to """
pid = ctypes.c_long()
pid = ctypes.c_ulong()
ctypes.windll.user32.GetWindowThreadProcessId(hwnd, ctypes.byref(pid))
return int(pid.value)
def getForegroundWindow(self):
Expand Down
12 changes: 7 additions & 5 deletions lackey/RegionMatching.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,9 +950,9 @@ def text(self):
""" OCR method. Todo. """
raise NotImplementedError("OCR not yet supported")

def mouseDown(self, button):
def mouseDown(self, button=Mouse.LEFT):
""" Low-level mouse actions. """
return PlatformManager.mouseButtonDown(button)
return Mouse.buttonDown(button)
def mouseUp(self, button=Mouse.LEFT):
""" Low-level mouse actions """
return Mouse.buttonUp(button)
Expand Down Expand Up @@ -1311,11 +1311,11 @@ def leftAt(self, offset=0):
def aboveAt(self, offset=0):
""" Returns point in the center of the region's top side (offset to the top
by negative ``offset``) """
return Location(self.getX() + (getW() / 2), self.getY() + offset)
return Location(self.getX() + (self.getW() / 2), self.getY() + offset)
def bottomAt(self, offset=0):
""" Returns point in the center of the region's bottom side (offset to the bottom
by ``offset``) """
return Location(self.getX() + (getW() / 2), self.getY() + self.getH() + offset)
return Location(self.getX() + (self.getW() / 2), self.getY() + self.getH() + offset)

def union(ur):
""" Returns a new region that contains both this region and the specified region """
Expand Down Expand Up @@ -1655,8 +1655,10 @@ def register_event(self, event_type, pattern, handler):
"""
if event_type not in self._supported_events:
raise ValueError("Unsupported event type {}".format(event_type))
if not isinstance(pattern, Pattern) and not isinstance(pattern, basestring):
if event_type != "CHANGE" and not isinstance(pattern, Pattern) and not isinstance(pattern, basestring):
raise ValueError("Expected pattern to be a Pattern or string")
if event_type == "CHANGE" and not (len(pattern)==2 and isinstance(pattern[0], int) and isinstance(pattern[1], numpy.ndarray)):
raise ValueError("For \"CHANGE\" events, ``pattern`` should be a tuple of ``min_changed_pixels`` and the base screen state.")

# Create event object
event = {
Expand Down
2 changes: 1 addition & 1 deletion lackey/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"""

__version__ = "0.7.1"
__version__ = "0.7.2"
__sikuli_version__ = "1.1.0"

0 comments on commit 887807e

Please sign in to comment.