Skip to content

Instantly share code, notes, and snippets.

@pikachu0310
Created October 16, 2019 11:22
Show Gist options
  • Save pikachu0310/ba807b7d799be75dca472fae927ae4c2 to your computer and use it in GitHub Desktop.
Save pikachu0310/ba807b7d799be75dca472fae927ae4c2 to your computer and use it in GitHub Desktop.
カビアドマクロちゃん
import pyautogui
import time
import random
import datetime
import time
class auto:
def nowClick(self, t=0.0):
time.sleep(t)
pyautogui.click()
def nowrClick(self, t=0.0):
time.sleep(t)
pyautogui.rightClick()
def Click(self, x, y, t=0.0):
time.sleep(t)
pyautogui.click(x=x, y=y)
def rClick(self, x, y, t=0.0):
time.sleep(t)
pyautogui.rightClick(x=x, y=y)
def move(self, x, y, t=0.0):
time.sleep(t)
pyautogui.moveTo(x=x, y=y)
def press(self, text, t=0.0):
time.sleep(t)
pyautogui.press(text)
def chat(self, text, t=0.0):
time.sleep(t)
pyautogui.typewrite(text)
def keydown(self, text, t=0.0):
time.sleep(t)
pyautogui.keyDown(text)
def keyup(self, text, t=0.0):
time.sleep(t)
pyautogui.keyUp(text)
def scroll(self, num, t=0.0):
time.sleep(t)
pyautogui.scroll(num)
def move_scroll(self, x, y, num, t=0.0):
time.sleep(t)
pyautogui.moveTo(x=x, y=y)
pyautogui.scroll(num)
def gazou_zahyou(self, file_name, confidence, t=0):
time.sleep(t)
try:
return pyautogui.center(pyautogui.locateOnScreen(file_name, confidence=confidence))
except Exception as E:
if "PyAutoGUI fail-safe triggered" in str(E):
print(0 / 0)
elif "Could not locate the image" in str(E):
print(E)
def gazou_zahyou_region(self, file_name, confidence, x, y, xx, yy, t=0):
time.sleep(t)
try:
return pyautogui.center(pyautogui.locateOnScreen(file_name, confidence=confidence, region=(x, y, xx-x, yy-y)))
except Exception as E:
if "PyAutoGUI fail-safe triggered" in str(E):
print(0 / 0)
elif "Could not locate the image" in str(E):
print(E)
def gazou_Click(self, file_name, confidence, t=0):
time.sleep(t)
try:
pyautogui.click(pyautogui.locateCenterOnScreen(file_name, confidence=confidence))
except Exception as E:
if "PyAutoGUI fail-safe triggered" in str(E):
print(0 / 0)
elif "Could not locate the image" in str(E):
print(E)
def gazou_Click_region(self, file_name, confidence, x, y, xx, yy, t=0):
time.sleep(t)
try:
pyautogui.click(pyautogui.center(pyautogui.locateOnScreen(file_name, confidence=confidence, region=(x, y, xx - x, yy - y))))
except Exception as E:
if "PyAutoGUI fail-safe triggered" in str(E):
print(0 / 0)
elif "Could not locate the image" in str(E):
print(E)
def check_gazou(self, file_name, confidence, t=0):
time.sleep(t)
try:
pyautogui.locateCenterOnScreen(file_name, confidence=confidence)
return True
except:
return False
def check_gazou_region(self, file_name, confidence, x, y, xx, yy, t=0):
time.sleep(t)
try:
pyautogui.center(pyautogui.locateOnScreen(file_name, confidence=confidence, region=(x, y, xx - x, yy - y)))
return True
except:
return False
def test(self):
while True:
cx, cy = pyautogui.position()
print(pyautogui.pixel(cx, cy))
print(cx, cy)
class kirby_adventure(auto):
def isekai(self):
try:
if self.check_gazou("full.png", 0.95):
x, y = self.gazou_zahyou("full.png", 0.95)
self.Click(x, y - 5)
time.sleep(1)
if self.check_gazou("kotya.png", 0.8):
print("こちゃ出現")
elif self.check_gazou("metarukingu.png", 0.8):
print("メタキン出現")
self.move_scroll(x, y - 5, -100000, 1)
self.move_scroll(x, y - 5, -100000, 0.1)
if self.check_gazou("master.png", 0.8):
print("職業をマスターしたため終了します")
input("このをタブ閉じてね")
elif self.check_gazou("level.png", 0.8):
print(f'レベルアップ! ({datetime.datetime.now().strftime("%m/%d %H:%M:%S")})')
x, y = self.gazou_zahyou("back.png", 0.95)
self.Click(x, y, 0.5)
time.sleep(1)
if self.check_gazou("ginkou.png", 0.9):
x, y = self.gazou_zahyou("ginkou.png", 0.9)
self.Click(x, y, 1)
time.sleep(1)
if self.check_gazou("azukeru.png", 0.95):
x, y = self.gazou_zahyou("azukeru.png", 0.95)
self.Click(x, y, 1)
time.sleep(1)
if self.check_gazou("back.png", 0.95):
x, y = self.gazou_zahyou("back.png", 0.95)
self.Click(x, y, 1)
time.sleep(1)
except Exception as E:
print(E)
if "PyAutoGUI fail-safe triggered" in str(E):
print(0 / 0)
else:
print("あああああエラーあああああ")
time.sleep(5)
if self.check_gazou("back.png", 0.95):
x, y = self.gazou_zahyou("back.png", 0.95)
self.Click(x, y, 1)
time.sleep(1)
def boss(self):
try:
if self.check_gazou("tyanputyousenn.png", 0.9):
x, y = self.gazou_zahyou("tyanpu.png", 0.95)
time.sleep(2)
self.Click(x, y)
time.sleep(2)
self.move_scroll(x, y, -100000, 1)
self.move_scroll(x, y, -100000, 0.1)
x, y = self.gazou_zahyou("back.png", 0.95)
self.Click(x, y, 0.5)
time.sleep(1)
elif self.check_gazou("boss.png", 0.95):
x, y = self.gazou_zahyou("boss.png", 0.95)
self.Click(x, y)
while True:
self.move_scroll(x, y, -100000, 3)
self.move_scroll(x, y, -100000, 0.1)
if self.check_gazou("master.png", 0.8):
print("職業をマスターしたため終了します")
input("このをタブ閉じてね")
elif self.check_gazou("level.png", 0.8):
print(f'レベルアップ! ({datetime.datetime.now().strftime("%m/%d %H:%M:%S")})')
if self.check_gazou("oku.png", 0.9):
x, y = self.gazou_zahyou("oku.png", 0.9)
self.Click(x, y)
time.sleep(1)
continue
elif self.check_gazou("make.png", 0.8) or self.check_gazou("nigeru.png", 0.8):
x, y = self.gazou_zahyou("back.png", 0.95)
self.Click(x, y, 1)
time.sleep(1)
if self.check_gazou("kaihuku.png", 0.9):
x, y = self.gazou_zahyou("kaihuku.png", 0.9)
self.Click(x, y, 1)
time.sleep(1)
if self.check_gazou("back.png", 0.95):
x, y = self.gazou_zahyou("back.png", 0.95)
self.Click(x, y, 1)
time.sleep(1)
break
except Exception as E:
print(E)
if "PyAutoGUI fail-safe triggered" in str(E):
print(0 / 0)
else:
print("あああああエラーあああああ")
while True:
kirby_adventure().boss()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment