daily pastebin goal
40%
SHARE
TWEET

Untitled

a guest Jan 17th, 2018 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class BehaviourManager(ClassMessage):
  2.  
  3.     def mouseClick(self, object, button):
  4.         self._mouseAction(self._convertPosition(object), button)
  5.  
  6.     def mouseDrag(self, object1, object2, button):
  7.         self._mouseAction(self._convertPosition(object1), button='left',
  8.                                callback=lambda position: self.__mouseDrag_InvokedCallback(position, object2))
  9.  
  10.     def _convertPosition(self, object):
  11.         if(isinstance(object, ImageMatchResult)):
  12.             return object.getRandomInnerPosition()
  13.         else:
  14.             return object
  15.  
  16.     def _mouseAction(self, position, button, callback=lambda position: position):
  17.         pyautogui.mouseDown(x=position[0], y=position[1], button=button)
  18.         position = callback(position)
  19.         pyautogui.mouseUp(x=position[0], y=position[1], button=button)
  20.  
  21.     def __mouseDrag_InvokedCallback(self, position, object):
  22.         Helpers.randomSleep(1000, 1500)
  23.         return self._convertPosition(object)
RAW Paste Data
Top