Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.62 KB | None | 0 0
  1.  
  2. import pyautogui, sys
  3. import time
  4. import pyperclip
  5. import random
  6. import string
  7.  
  8. print('Press Ctrl-Alt-Del to stop the bot.')
  9.  
  10. correctAnswers = []
  11. amountCorrect = len(correctAnswers)
  12. texts = []
  13. locations = []
  14. choices = []
  15. last = ['none','none','none','none','none']
  16. wrong = []
  17. laskuri = 0
  18.  
  19. while True:
  20.     print("Montako kysymystä?")
  21.     questions = int(input())
  22.     break
  23.  
  24. while (len(correctAnswers)) < questions-1:
  25.     time.sleep(1)
  26.     for i in range(5):
  27.         pyautogui.press('pgdn')
  28.     pos = None
  29.     done = False
  30.     while pos is None:
  31.         for pos in pyautogui.locateAllOnScreen('blue2.png'):
  32.             if done == False:
  33.                 pyautogui.moveTo(pos[0]-20,pos[1]+5)
  34.                 pyautogui.dragRel(700, 45, 0.2, button='left')
  35.                 pyautogui.hotkey('ctrl', 'c')
  36.                 valinta = pyperclip.paste()
  37.                 valinta = valinta.split(".")
  38.                 valinta = valinta[0]
  39.                 valinta.splitlines()
  40.                 texts.append(valinta)
  41.                 last.append(valinta)
  42.                 locations.append((pos[0]+5,pos[1]+5))
  43.                 choices.append((pos[0]+5,pos[1]+5))
  44.  
  45.     for i in range(correctAnswers):
  46.         for j in texts:
  47.             if correctAnswers[laskuri] == j:
  48.                 laskuri += 1
  49.                 pyautogui.click(locations[texts.index(j)])
  50.                 pyautogui.click(pyautogui.locateCenterOnScreen('next.png'))
  51.                 time.sleep(0.5)
  52.                 pyautogui.click(pyautogui.locateCenterOnScreen('next2.png'))
  53.                 pos = None
  54.                 while pos is None:
  55.                     for pos in pyautogui.locateAllOnScreen('blue2.png'):
  56.                         pyautogui.moveTo(pos[0]-20,pos[1]+5)
  57.                         pyautogui.dragRel(700, 45, 0.2, button='left')
  58.                         pyautogui.hotkey('ctrl', 'c')
  59.                         valinta = pyperclip.paste()
  60.                         valinta = valinta.split(".")
  61.                         valinta = valinta[0]
  62.                         valinta.splitlines()
  63.                         texts.append(valinta)
  64.                         last.append(valinta)
  65.                         locations.append((pos[0]+5,pos[1]+5))
  66.                         choices.append((pos[0]+5,pos[1]+5))
  67.  
  68.  
  69.  
  70.         #print("Correct answers: ",correctAnswers,"\n")
  71.         #print("Choices :",texts,"\n")
  72.         count = len(texts)
  73.         #print("Valintoja yhteensä: ", count)
  74.         #print(wrong)
  75.         texts = []
  76.         locations = []
  77.  
  78.     while True:
  79.         if last[-1] in wrong:
  80.             pass
  81.             if last[-2] in wrong:
  82.                 pass
  83.                 if last[-3] in wrong:
  84.                     pass
  85.                     if last[-4] in wrong:
  86.                         pyautogui.click(choices[-5])
  87.                     else:
  88.                         pyautogui.click(choices[-4])
  89.                 else:
  90.                     pyautogui.click(choices[-3])
  91.             else:
  92.                 pyautogui.click(choices[-2])
  93.         else:
  94.             pyautogui.click(choices[-1])
  95.  
  96.         if pyautogui.locateOnScreen('green.png') != None:
  97.             print("Correct answer\n")
  98.             laskuri += 1
  99.             if last[-1] in correctAnswers:
  100.                 pyautogui.click(pyautogui.locateCenterOnScreen('next.png'))
  101.                 time.sleep(0.5)
  102.                 pyautogui.click(pyautogui.locateCenterOnScreen('next2.png'))
  103.                 break
  104.             else:
  105.                 wrong = []
  106.                 #last = []
  107.                 choices = []
  108.                 green = pyautogui.locateOnScreen('green.png')
  109.                 pyautogui.moveTo(green[0],green[1])
  110.                 pyautogui.dragRel(700, 45, 0.2, button='left')
  111.                 pyautogui.hotkey('ctrl', 'c')
  112.                 rightAnswer = pyperclip.paste()
  113.                 rightAnswer = rightAnswer.split(".")
  114.                 rightAnswer = rightAnswer[0]
  115.                 rightAnswer = rightAnswer.splitlines()
  116.                 if len(rightAnswer) > 1:
  117.                     rightAnswer = rightAnswer[1]
  118.                 correctAnswers.append(rightAnswer)
  119.                 pyautogui.click(pyautogui.locateCenterOnScreen('next.png'))
  120.                 time.sleep(0.5)
  121.                 pyautogui.click(pyautogui.locateCenterOnScreen('next2.png'))
  122.                 break
  123.  
  124.         if pyautogui.locateOnScreen('green.png') == None:
  125.             print("Wrong answer\n")
  126.             laskuri = 0
  127.             wrong.append(last[-1])
  128.             pyautogui.click(pyautogui.locateCenterOnScreen('restart.png'))
  129.             for i in range(5):
  130.                 pyautogui.press('pgdn')
  131.             break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement