Reklam
pip install pyautoguiimport pyautogui
print(pyautogui.position()) # Mouse imlecinin bulunduğu koordinatları yazdırır
import pyautogui
import time
# Fonksiyonlar
def check_durability():
# Dayanıklılığı kontrol etme (bu kısım oyunun nasıl bilgi verdiğine bağlı)
# Örnek olarak dayanıklılığı ekrandan okuyarak kontrol edebilirsiniz (OCR kullanılabilir)
return pyautogui.locateOnScreen('durability_warning.png') is not None
def repair_weapon():
# Tamir etmek için kasabaya gitme
pyautogui.click(x=1000, y=500) # Kasaba simgesi
time.sleep(5) # Kasabaya gitme süresi
# Sundries NPC ile etkileşim
pyautogui.click(x=800, y=600) # Sundries NPC
time.sleep(2)
# Tamir etme
pyautogui.click(x=900, y=700) # Tamir seçeneği
time.sleep(2)
# Geri dönme
pyautogui.click(x=1000, y=500) # Yaratık alanı
time.sleep(5)
def main():
while True:
if check_durability():
repair_weapon()
# Bekleme süresi
time.sleep(10)
if __name__ == "__main__":
main()
pip install pyautogui opencv-pythonimport pyautogui
import cv2
import numpy as np
import time
# Can ve mana barlarının bulunduğu bölgelerin koordinatları
HEALTH_BAR_REGION = (100, 50, 200, 20) # X, Y, Width, Height
MANA_BAR_REGION = (100, 80, 200, 20)
# Kırmızı ve mavi renklerin aralıkları (BGR formatında)
RED_LOWER = np.array([0, 0, 150])
RED_UPPER = np.array([50, 50, 255])
BLUE_LOWER = np.array([150, 0, 0])
BLUE_UPPER = np.array([255, 50, 50])
def get_bar_percentage(region, lower_color, upper_color):
screenshot = pyautogui.screenshot(region=region)
frame = np.array(screenshot)
mask = cv2.inRange(frame, lower_color, upper_color)
percentage = cv2.countNonZero(mask) / (region[2] * region[3])
return percentage
def use_health_potion():
pyautogui.press('1') # Can potunun kısayolu
def use_mana_potion():
pyautogui.press('2') # Mana potunun kısayolu
def main():
while True:
health_percentage = get_bar_percentage(HEALTH_BAR_REGION, RED_LOWER, RED_UPPER)
mana_percentage = get_bar_percentage(MANA_BAR_REGION, BLUE_LOWER, BLUE_UPPER)
if health_percentage < 0.3: # Can %30'un altına düştüğünde
use_health_potion()
if mana_percentage < 0.3: # Mana %30'un altına düştüğünde
use_mana_potion()
time.sleep(1) # Her 1 saniyede bir kontrol et
if __name__ == "__main__":
main()
import pyautogui
import cv2
import numpy as np
import time
# Hedef yaratığın ekran görüntüsü dosyasının yolu
TARGET_IMAGE_PATH = 'troll.png'
# Hedef yaratığı tespit etmek için bir eşik değeri
THRESHOLD = 0.8
def locate_target(image_path):
screenshot = pyautogui.screenshot()
screenshot = cv2.cvtColor(np.array(screenshot), cv2.COLOR_BGR2RGB)
target_image = cv2.imread(image_path, cv2.IMREAD_COLOR)
result = cv2.matchTemplate(screenshot, target_image, cv2.TM_CCOEFF_NORMED)
locations = np.where(result >= THRESHOLD)
if len(locations[0]) > 0:
return pyautogui.center(locations)
return None
def attack_target(target_location):
if target_location:
pyautogui.click(target_location) # Hedefe tıklama
pyautogui.press('space') # Saldırı tuşu (oyuna göre değişebilir)
def main():
while True:
target_location = locate_target(TARGET_IMAGE_PATH)
if target_location:
attack_target(target_location)
time.sleep(1) # Her 1 saniyede bir kontrol et
if __name__ == "__main__":
main()