Advertisement
renix1

main

Feb 20th, 2017
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.45 KB | None | 0 0
  1. import pyautogui
  2. import pyperclip
  3. import logging
  4. import time
  5. import os
  6.  
  7. logging.basicConfig(level=logging.INFO)
  8. clicks_total = 0
  9.  
  10. def click_blank_space():
  11.     name = 'blank_space.png'
  12.     if os.path.exists(name):
  13.         logging.info("Há o item %s na pasta" % name)
  14.         blank = pyautogui.locateCenterOnScreen(name, grayscale=True)
  15.         if not blank is None:
  16.             pyautogui.click(blank)
  17.             logging.info("Cliquei no espaço em branco...")
  18.  
  19. def detect_shirt():
  20.     name = 'shirt.png'
  21.     if os.path.exists(name):
  22.         logging.info("Há o item %s na pasta" % name)
  23.         click_blank_space()
  24.         shirt = pyautogui.locateOnScreen(name, grayscale=True)
  25.         if not shirt is None:
  26.             x, y = shirt[0]+26, shirt[1]+20
  27.             logging.info("Camisa encontrada em {} pixels" .format(shirt))
  28.             logging.info("Posicionando o mouse...")
  29.             pyautogui.moveTo(x, y)
  30.             pyautogui.click()
  31.             scroll_page_submit()
  32.         else:
  33.             logging.info("Camisa não foi encontrada")
  34.  
  35. def detect_submit():
  36.     global clicks_total
  37.     name = 'submit_button.png'
  38.     if os.path.exists(name):
  39.         logging.info("Há o item %s na pasta" % name)
  40.         submit_button = pyautogui.locateCenterOnScreen(name, grayscale=True)
  41.         if not submit_button is None:
  42.             logging.info("Botão encontrado em {} pixels" .format(submit_button))
  43.             logging.info("Posicionando o mouse...")
  44.             pyautogui.moveTo(submit_button)
  45.             logging.info("Clicando no botão...")
  46.             pyautogui.click()
  47.             clicks_total += 1
  48.             logging.info("Já fiz isso %d vezes" % clicks_total)
  49.             time.sleep(2)
  50.             while not detect_finished():
  51.                 pass
  52.             else:
  53.                 detect_finished()
  54.         else:
  55.             logging.info("Botão não encontrado")
  56.             return False
  57.  
  58. def detect_text_area():
  59.     name = 'text_area.png'
  60.     link = r"https://docs.google.com/forms/d/e/1FAIpQLScVOHG1Bwiamo3eNRIIJeuPBCTvgmj1S34LdlaoWNE7g0YF9w/viewform?fbzx=-7042229523293071000"
  61.     if os.path.exists(name):
  62.         logging.info("Há o item %s na pasta" % name)
  63.         text = pyautogui.locateCenterOnScreen(name, grayscale=True)
  64.         if not text is None:
  65.             logging.info("Campo de texto encontrado.")
  66.             pyautogui.click(text)
  67.             pyautogui.hotkey('ctrl', 'a')
  68.             pyautogui.press('delete')
  69.             pyautogui.click(text)
  70.             pyperclip.copy(link)
  71.             pyautogui.hotkey('ctrl', 'v')
  72.             logging.info("Reentrando no site...")
  73.             pyautogui.press('return')
  74.             main()
  75.         else:
  76.             logging.info(text)
  77.  
  78. def detect_finished():
  79.     name = 'finished.png'
  80.     if os.path.exists(name):
  81.         logging.info("Há o item %s na pastas" % name)
  82.         finished = pyautogui.locateOnScreen(name)
  83.         if not finished is None:
  84.             logging.info("Já foi finalizado. Refazendo...")
  85.             detect_text_area()
  86.         else:
  87.             logging.info(finished)
  88.  
  89.  
  90. def scroll_page_submit():
  91.     while not detect_submit():
  92.         pyautogui.scroll(-10000)
  93.     else:
  94.         detect_submit()
  95.  
  96. def scroll_page_shirt():
  97.     if not detect_shirt():
  98.         pyautogui.scroll(-3500)
  99.         time.sleep(1.3)
  100.     else:
  101.         detect_shirt()
  102.  
  103. def main():
  104.     while 1:
  105.         scroll_page_shirt()
  106.  
  107. if __name__ == "__main__":
  108.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement