Skip to content

Instantly share code, notes, and snippets.

@pikachu0310
Created April 15, 2020 16:12
Show Gist options
  • Save pikachu0310/10ae0bd61b2089162b6a250d8472182b to your computer and use it in GitHub Desktop.
Save pikachu0310/10ae0bd61b2089162b6a250d8472182b to your computer and use it in GitHub Desktop.
thufo用
import pyautogui
import time
import random
import datetime
import time
import pyperclip
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:
if pyautogui.locateCenterOnScreen(file_name, confidence=confidence) is None:
return False
else:
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 copipe(self, text):
pyperclip.copy(text)
pyautogui.hotkey('ctrl', 'v')
def test(self):
while True:
cx, cy = pyautogui.position()
print(pyautogui.pixel(cx, cy))
print(cx, cy)
class main(auto):
def main(self):
self.nyuuryoku()
self.taiki()
self.roguinn()
self.annkeeto1()
self.annkeeto2()
self.kaitou1()
self.kaitou2()
self.kaitou3()
self.kaitou4()
self.annkeeto3()
def nyuuryoku(self):
while True:
try:
inp = input("何時何分に送信しますか?(classi遅いからラグできるけど)"
"\n入力方法: 07:06 みたいに、24時制で入力してね。"
"\n入力例: 08:09 14:55 07:15"
"\n入力どうぞ→")
if len(inp) == 5:
if inp[2] == ":":
self.inp_hour = int(inp[0:2])
self.inp_minute = int(inp[3:5])
print(f"君の入力は、 {inp} だよ。 "
f"\nokだったらokって入力してね! ok以外を入力すれば再入力できるよ。")
inp2 = input("入力どうぞ→")
if inp2 == "ok" or inp2 == "Ok":
break
else:
print("再入力!")
else:
print(f"入力エラー! ちゃんと入力してよぅ!\n君の入力は, {inp} だったよ。\n 再入力!")
else:
print(f"入力エラー! ちゃんと入力してよぅ!\n君の入力は, {inp} だったよ。\n 再入力!")
except:
print(f"入力エラー! ちゃんと入力してよぅ!\n君の入力は, {inp} だったよ。\n 再入力!")
while True:
try:
inp = input("今朝の体温は何度ですか? で回答したい選択肢を 数字 でこたえてね。"
"\n1 36.5度未満"
"\n2 36.5~36.9度"
"\n3 37.0~37.4度"
"\n4 37.5~37.9度"
"\n5 38以上"
"\n入力例: 2 4 5"
"\n入力どうぞ→")
if len(inp) == 1 and inp in ["1", "2", "3", "4", "5"]:
self.inp1 = int(inp)
print(f"君の入力は、 {inp} だよ。 "
f"\nokだったらokって入力してね! ok以外を入力すれば再入力できるよ。")
inp2 = input("入力どうぞ→")
if inp2 == "ok" or inp2 == "Ok":
break
else:
print("再入力!")
else:
print(f"入力エラー! ちゃんと入力してよぅ!\n君の入力は, {inp} だったよ。\n 再入力!")
except:
print(f"入力エラー! ちゃんと入力してよぅ!\n君の入力は, {inp} だったよ。\n 再入力!")
while True:
try:
inp = input("昨晩はよく眠れましたか? で回答したい選択肢を 数字 でこたえてね。"
"\n1 よく眠れた"
"\n2 あまり眠れなかった"
"\n入力例: 1 2 1"
"\n入力どうぞ→")
if len(inp) == 1 and inp in ["1", "2"]:
self.inp2 = int(inp)
print(f"君の入力は、 {inp} だよ。 "
f"\nokだったらokって入力してね! ok以外を入力すれば再入力できるよ。")
inp2 = input("入力どうぞ→")
if inp2 == "ok" or inp2 == "Ok":
break
else:
print("再入力!")
else:
print(f"入力エラー! ちゃんと入力してよぅ!\n君の入力は, {inp} だったよ。\n 再入力!")
except:
print(f"入力エラー! ちゃんと入力してよぅ!\n君の入力は, {inp} だったよ。\n 再入力!")
while True:
try:
inp = input("今朝の気分はどうですか? で回答したい選択肢を 数字 でこたえてね。"
"\n1 ^v^"
"\n2 ^A^"
"\n3 -v-"
"\n4 x_x"
"\n入力例: 1 3 4"
"\n入力どうぞ→")
if len(inp) == 1 and inp in ["1", "2", "3", "4"]:
self.inp3 = int(inp)
print(f"君の入力は、 {inp} だよ。 "
f"\nokだったらokって入力してね! ok以外を入力すれば再入力できるよ。")
inp2 = input("入力どうぞ→")
if inp2 == "ok" or inp2 == "Ok":
break
else:
print("再入力!")
else:
print(f"入力エラー! ちゃんと入力してよぅ!\n君の入力は, {inp} だったよ。\n 再入力!")
except:
print(f"入力エラー! ちゃんと入力してよぅ!\n君の入力は, {inp} だったよ。\n 再入力!")
while True:
print("今朝のひとことを書きましょう。(今日の気持ち、最近気になったこと、先生に伝えたいことなど)"
"\n で入力することを 入力してね。 改行できます。 入力し終えたら、改行してからquitとだけ入力してください。"
"\n入力例: "
"\nうーん。 "
"\n良い目覚め! "
"\nquit\n\n↓入力どうぞ↓")
inp_str = ""
while True:
inp = input()
if inp in ["quit", "QUIT", "Quit"]:
break
else:
inp_str += inp + "\n"
if len(inp_str) == 0:
print("いや何か打ち込めよw 再入力!")
else:
self.inp4 = inp_str
print(f"君の入力は、\n {inp_str} だよ。 "
f"\nokだったらokって入力してね! ok以外を入力すれば再入力できるよ。")
inp2 = input("入力どうぞ→")
if inp2 == "ok" or inp2 == "Ok":
break
else:
print("再入力!")
def taiki(self):
inp_time = datetime.timedelta(hours=self.inp_hour, minutes=self.inp_minute).seconds
while True:
time.sleep(1)
dt = datetime.datetime.now()
now = datetime.timedelta(hours=dt.hour, minutes=dt.minute, seconds=dt.second).seconds
if inp_time <= now:
break
else:
if int(inp_time) - int(now) >= 3000:
print(f"待機中です... 後 {round((int(inp_time) - int(now))/60, 1)} 分")
time.sleep(1800)
elif int(inp_time) - int(now) >= 1600:
print(f"待機中です... 後 {round((int(inp_time) - int(now))/60, 1)} 分")
time.sleep(1200)
elif int(inp_time) - int(now) >= 400:
print(f"待機中です... 後 {round((int(inp_time) - int(now))/60, 1)} 分")
time.sleep(300)
elif int(inp_time) - int(now) >= 100:
time.sleep(29)
print(f"待機中です... 後 {int(inp_time) - int(now)} 秒")
elif int(inp_time) - int(now) >= 15:
time.sleep(9)
print(f"待機中です... 後 {int(inp_time) - int(now)} 秒")
else:
print(f"待機中です... 後 {int(inp_time) - int(now)} 秒")
def roguinn(self):
while True:
if self.check_gazou("roguinn1.PNG", 0.8, 1):
self.gazou_Click("roguinn1.PNG", 0.8)
break
else:
print("待機中 roguinn-1")
while True:
if self.check_gazou("roguinn2.PNG", 0.8, 1):
self.gazou_Click("roguinn2.PNG", 0.8)
break
else:
print("待機中 roguinn-2")
def annkeeto1(self):
while True:
if self.check_gazou("botann1.PNG", 0.8, 1):
self.gazou_Click("botann1.PNG", 0.8)
break
else:
print("待機中 ankeeto1-1")
while True:
if self.check_gazou("botann2.PNG", 0.8, 1):
self.gazou_Click("botann2.PNG", 0.8)
break
else:
print("待機中 ankeeto1-2")
def annkeeto2(self):
while True:
if self.check_gazou("botann3.PNG", 0.8, 1):
self.gazou_Click("botann3.PNG", 0.8)
break
else:
print("待機中 ankeeto2-1")
while True:
if self.check_gazou("botann4.PNG", 0.8, 1):
self.gazou_Click("botann4.PNG", 0.8)
break
else:
print("待機中 ankeeto2-2")
def kaitou1(self):
while True:
if self.check_gazou("check1.PNG", 0.8, 1):
break
else:
print("待機中... kaitou1-1")
if self.inp1 == 1:
while True:
if self.check_gazou("botann5.PNG", 0.8, 1):
self.gazou_Click("botann5.PNG", 0.8)
break
else:
print("待機中... kaitou1-2")
elif self.inp1 == 2:
while True:
if self.check_gazou("botann6.PNG", 0.8, 1):
self.gazou_Click("botann6.PNG", 0.8)
break
else:
print("待機中... kaitou1-3")
elif self.inp1 == 3:
while True:
if self.check_gazou("botann7.PNG", 0.8, 1):
self.gazou_Click("botann7.PNG", 0.8)
break
else:
print("待機中... kaitou1-4")
elif self.inp1 == 4:
while True:
if self.check_gazou("botann8.PNG", 0.8, 1):
self.gazou_Click("botann8.PNG", 0.8)
break
else:
print("待機中... kaitou1-5")
elif self.inp1 == 5:
while True:
if self.check_gazou("botann9.PNG", 0.8, 1):
self.gazou_Click("botann9.PNG", 0.8)
break
else:
print("待機中... kaitou1-6")
def kaitou2(self):
self.scroll(-500)
time.sleep(2)
while True:
if self.check_gazou("check2.PNG", 0.8, 1):
break
else:
print("待機中... kaitou2-1")
self.scroll(-10)
if self.inp2 == 1:
while True:
if self.check_gazou("botann10.PNG", 0.8, 1):
self.gazou_Click("botann10.PNG", 0.8)
break
else:
print("待機中... kaitou2-2")
elif self.inp2 == 2:
while True:
if self.check_gazou("botann11.PNG", 0.8, 1):
self.gazou_Click("botann11.PNG", 0.8)
break
else:
print("待機中... kaitou2-3")
def kaitou3(self):
self.scroll(-200)
time.sleep(2)
while True:
if self.check_gazou("check3.PNG", 0.8, 1):
break
else:
print("待機中... kaitou3-1")
self.scroll(-10)
if self.inp3 == 1:
while True:
if self.check_gazou("botann12.PNG", 0.85, 1):
self.gazou_Click("botann12.PNG", 0.85)
break
else:
print("待機中... kaitou3-2")
self.scroll(-10)
elif self.inp3 == 2:
while True:
if self.check_gazou("botann13.PNG", 0.85, 1):
self.gazou_Click("botann13.PNG", 0.85)
break
else:
print("待機中... kaitou3-3")
self.scroll(-10)
elif self.inp3 == 3:
while True:
if self.check_gazou("botann14.PNG", 0.85, 1):
self.gazou_Click("botann14.PNG", 0.85)
break
else:
print("待機中... kaitou3-4")
self.scroll(-10)
elif self.inp3 == 4:
while True:
if self.check_gazou("botann15.PNG", 0.85, 1):
self.gazou_Click("botann15.PNG", 0.85)
break
else:
print("待機中... kaitou3-5")
self.scroll(-10)
def kaitou4(self):
self.scroll(-900)
while True:
if self.check_gazou("check4.PNG", 0.8, 1):
break
else:
print("待機中... kaitou4-1")
self.scroll(-10)
while True:
if self.check_gazou("botann16.PNG", 0.8, 1):
self.gazou_Click("botann16.PNG", 0.8)
time.sleep(1)
self.copipe(self.inp4)
break
else:
print("待機中... kaitou4-2")
self.scroll(-10)
def annkeeto3(self):
while True:
if self.check_gazou("botann17.PNG", 0.8, 1):
self.gazou_Click("botann17.PNG", 0.8)
break
else:
print("待機中 ankeeto3-1")
time.sleep(10)
self.scroll(-10000)
while True:
self.scroll(5)
if self.check_gazou("botann18.PNG", 0.8, 5):
self.gazou_Click("botann18.PNG", 0.8)
break
else:
print("待機中 ankeeto3-2")
print("")
time.sleep(1)
main().main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment