Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # coding:utf-8
- import pyautogui as pyag
- import os
- class Sender(object):
- def __init__(self, pos):
- self.pos = pos
- self._on_position()
- def _on_position(self):
- pyag.click(self.pos)
- def send_message(self, message, times=3):
- for time in range(0, times, 1):
- print('Mensagens enviadas: {}'.format(time))
- pyag.typewrite(message)
- pyag.press('enter')
- def send_chars(self, chars, times=3):
- chars = chars.replace(' ', '')
- for time in range(0, times, 1):
- print('Mensagens enviadas: {}'.format((time+1)*len(chars)))
- for char in chars:
- pyag.typewrite(char)
- pyag.press('enter')
- def send_message_creating(self, message):
- length = len(message)
- for i in range(0, length, 1):
- pyag.typewrite(message[:i+1])
- pyag.press('enter')
- def send_message_creating_inverse(self, message):
- length = len(message)
- for i in range(length, 0, -1):
- pyag.typewrite(message[i-1:])
- pyag.press('enter')
- def send_message_from_full(self, message):
- length = len(message)
- for i in range(length, 0, -1):
- pyag.typewrite(message[:i])
- pyag.press('enter')
- def triangle(self, message):
- self.send_message_creating(message)
- self.send_message_from_full(message)
- class Recognizer(object):
- IMAGES_PATH = os.path.join(os.getcwd(), 'images')
- def __init__(self, image_path):
- self._image_path = os.path.join(self.IMAGES_PATH, image_path)
- def run(self):
- location = pyag.locateCenterOnScreen(self._image_path, grayscale=1)
- if location is not None:
- sender = Sender(location)
- return sender
- else:
- return None
- if __name__ == '__main__':
- s = Recognizer('wpp.png').run()
- if isinstance(s, Sender):
- s.send_chars('Opa!')
- else:
- print('Não há mensageiro detectado na tela...')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement