파이썬 이미지 매크로 게임 자동 플레이(슬램덩크)
엘디 플레이어에서 편하게 스크립트 기능으로 구현 가능하지만
컴터가 구려서 그런지.. 약간의 딜레이가 생기면 뻑이 나는 경우가 많다.
그래서 스크린샷 이미지로 만들어봄...
파이썬을 하나도 모르기에 찾아가면서 만들어서.... 형편 없을것 같지만
일단 뭐 잘 굴러간다...
부캐들 일일 숙제 클릭하는것도 귀찮아서... 반복적인 행동을 줄이기 위해
만들었음
#사용된 라이브러리
import pyautogui
import pyautogui as pg
import time
import random
#이미지 저장
img_pvp = (r'F:\slam\est\pvp.jpg')
img_pvp2v2 = (r'F:\slam\est\pvp2v2hing.jpg')
img_start = (r'F:\sl.jpg')
img_matching = (r'F:\slam\est\matcam\est\start.jpg')
img_givup0 = (r'F:\slam\est\givup0.jpg')
img_givup = (r'F:\slam\est\givup.jpg')
img_go = (r'F:\slam\est\go.jpg')
img_go1 = (r'F:\slam\est\go1.jpg')
img_onemore = (r'F:\slam\est\onemore.jpg')
img_away = (r'F:\slam\est\qaway.jpg')
#이미지변수
timg_away = pyautogui.locateOnScreen(r'F:\slam\est\qaway.jpg', confidence=0.95)
timg_pvp = pyautogui.locateOnScreen(r'F:\slam\est\pvp.jpg', confidence=0.95)
timg_pvp2v2 = pyautogui.locateOnScreen(r'F:\slam\est\pvp2v2.jpg', confidence=0.95)
timg_matching = pyautogui.locateOnScreen(r'F:\slam\est\matching.jpg', confidence=0.95)
timg_start = pyautogui.locateOnScreen(r'F:\slam\est\start.jpg', confidence=0.95)
timg_po0 = pyautogui.locateOnScreen(r'F:\slam\est\PO0.jpg', confidence=0.95)
timg_po = pyautogui.locateOnScreen(r'F:\slam\est\po.jpg', confidence=0.95)
timg_pogi_dis = pyautogui.locateOnScreen(r'F:\slam\est\pogi_dis.jpg', confidence=0.8)
timg_pogi_ena= pyautogui.locateOnScreen(r'F:\slam\est\pogi_ena.jpg', confidence=0.7)
timg_go = pyautogui.locateOnScreen(r'F:\slam\est\go.jpg', confidence=0.95)
timg_go1 = pyautogui.locateOnScreen(r'F:\slam\est\go1.jpg', confidence=0.95)
timg_onemore = pyautogui.locateOnScreen(r'F:\slam\est\onemore.jpg', confidence=0.95)
timg_sel1 = pyautogui.locateOnScreen(r'F:\slam\est\sel1.jpg', confidence=0.95)
timg_time01 = pyautogui.locateOnScreen(r'F:\slam\est\time01.jpg', confidence=0.80)
timg_time02 = pyautogui.locateOnScreen(r'F:\slam\est\time02.jpg', confidence=0.80)
timg_test8 = pyautogui.locateOnScreen(r'F:\slam\est\TEST8.jpg', confidence=0.95)
timg_test5 = pyautogui.locateOnScreen(r'F:\slam\est\TEST5.jpg', confidence=0.95)
def pogi():
while True :
print("while 실행")
time.sleep(5)
print("대기중")
xy = print(pyautogui.position())
print(xy)
if pyautogui.locateOnScreen(r'F:\slam\est\real01.png', confidence=0.98):
pyautogui.moveTo(pyautogui.locateOnScreen(r'F:\slam\est\qaway.jpg', confidence=0.95))
pyautogui.moveRel(915, 0)
pyautogui.click(button='left')
xy = print(pyautogui.position())
print(xy)
time.sleep(1)
print("포기 실행")
time.sleep(1)
pyautogui.moveTo(pyautogui.locateOnScreen(r'F:\slam\est\qaway.jpg', confidence=0.95))
time.sleep(1)
pyautogui.moveRel(830, 465)
time.sleep(1)
pyautogui.click(button='left')
break
def check():
time.sleep(10)
if pyautogui.locateOnScreen(r'F:\slam\est\real01.png', confidence=0.98):
print("포기 실패 재시도")
pyautogui.moveTo(pyautogui.locateOnScreen(r'F:\slam\est\qaway.jpg', confidence=0.95))
pyautogui.moveRel(915, 0)
pyautogui.click(button='left')
xy = print(pyautogui.position())
print(xy)
time.sleep(1)
print("포기 실행")
time.sleep(1)
pyautogui.moveTo(pyautogui.locateOnScreen(r'F:\slam\est\qaway.jpg', confidence=0.95))
time.sleep(1)
pyautogui.moveRel(830, 465)
time.sleep(1)
else :
print("포기 성공")
def select():
test = pyautogui.locateOnScreen('F:\slam\est\sel1.jpg', confidence=0.9)
point = pg.center(test) # Box 객체의 중앙 좌표를 리턴합니다.
print(point)
pyautogui.moveTo(point)
pyautogui.moveRel(28, -288)
pyautogui.dragRel(-10, -300, 1, button='left')
time.sleep(random.randint(1, 2))
pyautogui.moveTo(point)
pyautogui.moveRel(100, -288)
pyautogui.dragRel(-10, -300, 1, button='left')
time.sleep(random.randint(1, 2))
pyautogui.moveTo(point)
pyautogui.moveRel(100, -288)
pyautogui.dragRel(-10, -300, 1, button='left')
time.sleep(random.randint(1, 2))
pyautogui.moveTo(point)
pyautogui.moveRel(100, -288)
pyautogui.dragRel(-10, -300, 1, button='left')
time.sleep(1)
pyautogui.moveTo(point)
pyautogui.moveRel(100, -258)
pyautogui.dragRel(-10, -300, 1, button='left')
time.sleep(1)
print("캐릭 고르기")
#캐릭터 선택 달재 등등
pyautogui.moveTo(point)
pyautogui.moveRel(48, -288)
dal1 = pyautogui.position()
print(dal1)
pyautogui.click(button='left')
time.sleep(1)
pyautogui.moveTo(point)
pyautogui.moveRel(-80, -296)
dal2 = pyautogui.position()
print(dal2)
pyautogui.click(button='left')
time.sleep(1)
pyautogui.moveTo(point)
pyautogui.moveRel(-86, -146)
dal3=pyautogui.position()
print(dal3)
pyautogui.click(button='left')
time.sleep(1.5)
pyautogui.moveTo(point)
pyautogui.moveRel(60, -156)
dal4=pyautogui.position()
print(dal4)
pyautogui.click(button='left')
time.sleep(1.5)
pyautogui.moveTo(point)
time.sleep(0.5)
pyautogui.click(button='left')
time.sleep(40)
#매인 대전 입장
try:
pyautogui.click(pyautogui.locateCenterOnScreen('F:\slam\est\pvp.jpg',confidence=0.9))
time.sleep(2)
time.sleep(random.randint(1,3))
print("대전입장")
except :
time.sleep(10)
pyautogui.click(pyautogui.locateCenterOnScreen('F:\slam\est\pvp.jpg',confidence=0.9))
time.sleep(4)
time.sleep(random.randint(1,3))
print("대전입장 재시도")
#2:2 대전 입장
try:
pyautogui.click(pyautogui.locateCenterOnScreen('F:\slam\est\pvp2v2.jpg',confidence=0.8))
time.sleep(4)
time.sleep(random.randint(1,3))
print("2:2대전입장")
except :
time.sleep(5)
pyautogui.click(pyautogui.locateCenterOnScreen('F:\slam\est\pvp2v2.jpg',confidence=0.8))
time.sleep(random.randint(1,2))
print("2:2대전입장 재시도")
i = 0
while i < 20:
while True:
print("매칭 시작")
if pyautogui.locateCenterOnScreen(r'F:\slam\est\matching.jpg', confidence=0.8):
pyautogui.click(pyautogui.locateCenterOnScreen(r'F:\slam\est\matching.jpg', confidence=0.8))
print("매칭 클릭")
time.sleep(1)
else :
time.sleep(10)
pyautogui.click(pyautogui.locateCenterOnScreen(r'F:\slam\est\matching.jpg', confidence=0.8))
break
while True:
print("시합 시작")
if pyautogui.locateCenterOnScreen(r'F:\slam\est\start.jpg',confidence=0.8):
pyautogui.click(pyautogui.locateCenterOnScreen(r'F:\slam\est\start.jpg',confidence=0.8))
print("시합시작 클릭")
time.sleep(1)
else :
time.sleep(8)
pyautogui.click(pyautogui.locateCenterOnScreen(r'F:\slam\est\start.jpg', confidence=0.8))
break
select()
print("캐릭터 선택 완료")
pogi()
print("포기 완료")
check()
print("체크 완료")
time.sleep(5)
#특훈이다 클릭
while True:
print("특훈이다 클릭")
if pyautogui.locateCenterOnScreen(r'F:\slam\est\gt1.jpg', confidence=0.7):
pyautogui.click(pyautogui.locateCenterOnScreen(r'F:\slam\est\gt1.jpg', confidence=0.8))
print("클릭 성공")
time.sleep(1)
else:
print("특훈이다 클릭 실패 재시도")
time.sleep(10)
pyautogui.click(pyautogui.locateCenterOnScreen(r'F:\slam\est\gt1.jpg', confidence=0.8))
print("클릭 성공")
break
# 계속 클릭
while True:
print("첫번째계속 클릭")
if pyautogui.locateCenterOnScreen(r'F:\slam\est\go.jpg', confidence=0.9):
pyautogui.click(pyautogui.locateCenterOnScreen(r'F:\slam\est\go.jpg', confidence=0.9))
print("계속 클릭 성공")
time.sleep(5)
else :
time.sleep(5)
pyautogui.click(pyautogui.locateCenterOnScreen(r'F:\slam\est\gt1.jpg', confidence=0.8))
time.sleep(0.5)
pyautogui.click(pyautogui.locateCenterOnScreen(r'F:\slam\est\go.jpg', confidence=0.9))
break
#두번째 계속 클릭
while True :
print("두번째계속 클릭")
if pyautogui.locateCenterOnScreen(r'F:\slam\est\go1.jpg', confidence=0.9):
pyautogui.click(pyautogui.locateCenterOnScreen(r'F:\slam\est\go1.jpg', confidence=0.9))
print("계속 클릭 성공")
time.sleep(5)
else :
time.sleep(3)
pyautogui.click(pyautogui.locateCenterOnScreen(r'F:\slam\est\go.jpg', confidence=0.9))
break
#한번더 클릭
while True:
print("한번더 클릭")
if pyautogui.locateCenterOnScreen(r'F:\slam\est\onemore.jpg', confidence=0.9):
pyautogui.click(pyautogui.locateCenterOnScreen(r'F:\slam\est\onemore.jpg', confidence=0.9))
print("한번더 클릭 완료")
time.sleep(5)
else :
time.sleep(1.5)
pyautogui.click(pyautogui.locateCenterOnScreen(r'F:\slam\est\go1.jpg', confidence=0.9))
break
i = i + 1
print(i)
print("실행함")
if i == 20 :
print("2 vs 2 종료")
break