-
-
Save pikachu0310/19dd885b7423fc03cc037669ced023c6 to your computer and use it in GitHub Desktop.
kirby_adventure_v1.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 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 mainloop(self): | |
try: | |
if self.check_gazou("full.png", 0.95): | |
self.Click(self.gazou_zahyou("full.png", 0.95)[0] + 60, self.gazou_zahyou("full.png", 0.95)[1] - 5) | |
self.scroll(-100000, 3) | |
auto().scroll(-100000, t=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")})') | |
self.Click(self.gazou_zahyou("back.png", 0.95)[0], self.gazou_zahyou("back.png", 0.95)[1], 0.5) | |
else: | |
self.Click(self.gazou_zahyou("back.png", 0.95)[0], self.gazou_zahyou("back.png", 0.95)[1], 0.5) | |
except Exception as E: | |
print(E) | |
if "PyAutoGUI fail-safe triggered" in str(E): | |
print(0 / 0) | |
else: | |
if random.random() > 0.5: | |
auto().scroll(-100000, t=0.1) | |
else: | |
auto().scroll(100000, t=0.1) | |
while True: | |
kirby_adventure().mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment