aaaa

import pyautogui
import keyboard
import time

craft_slots = [
   (858, 410), (893, 411), (932, 411),
   (860, 447), (892, 448), (928, 447),
   (858, 484), (899, 484), (935, 484)
]

result_slot = (1046, 444)
extra_slot = (1105, 660)

keys = ["1", "2", "3", "4", "5", "6", "7", "8", "x"]

drop_coords = [
   (931, 545), (971, 543), (1005, 546), (1042, 546),
   (1078, 547), (1113, 547), (1150, 548), (1185, 548),
   (1221, 547), (1227, 577), (1184, 579), (1155, 581),
   (1124, 581), (1076, 582), (1041, 583), (1006, 583),
   (972, 583), (933, 580), (935, 620), (976, 618),
   (1010, 617), (1036, 617), (1086, 615), (1117, 615),
   (1146, 615), (1180, 615), (1219, 615), (1225, 655),
   (1188, 658), (1147, 658), (1116, 659), (1079, 659),
   (1051, 659), (1007, 660), (972, 660), (935, 660)
]

# CRAFT HIZ AYARLARI
MOVE_TIME = 0
AFTER_MOVE = 0.015
KEY_HOLD = 0.0675
AFTER_KEY = 0.012

# SHIFT + SOL TIK AYARLARI
BEFORE_SHIFT_CLICK = 0.105
SHIFT_HOLD = 0.09
CLICK_WAIT = 0.09
AFTER_SHIFT = 0.06

# CTRL + Q HIZ AYARLARI
DROP_MOVE_TIME = 0
DROP_AFTER_MOVE = 0.0045
CTRL_HOLD = 0.015
Q_HOLD = 0.015
DROP_AFTER_Q = 0.009
drop_running = False

pyautogui.PAUSE = 0

print("Crafting table açık olsun.")
print("'.' = Craft çalıştır")
print("'-' = Ctrl+Q sistemi aç/kapat")
print("',' = Çıkış")

def press_key_fast(key):
   keyboard.press(key)
   time.sleep(KEY_HOLD)
   keyboard.release(key)
   time.sleep(AFTER_KEY)

def shift_click(x, y):
   time.sleep(BEFORE_SHIFT_CLICK)

   pyautogui.moveTo(x, y, duration=MOVE_TIME)
   time.sleep(0.05)

   keyboard.press("shift")
   time.sleep(SHIFT_HOLD)

   pyautogui.click()
   time.sleep(CLICK_WAIT)

   keyboard.release("shift")
   time.sleep(AFTER_SHIFT)

def craft_once():
   print("Craft başladı.")

   for i, (x, y) in enumerate(craft_slots):
       pyautogui.moveTo(x, y, duration=MOVE_TIME)
       time.sleep(AFTER_MOVE)
       press_key_fast(keys[i])

   shift_click(*result_slot)
   shift_click(*extra_slot)

   print("Craft bitti.")

def sleep_check_cancel(seconds):
   global drop_running

   start = time.time()
   while time.time() - start < seconds:
       if keyboard.is_pressed("-"):
           drop_running = False
           while keyboard.is_pressed("-"):
               time.sleep(0.02)
           return True
       time.sleep(0.001)

   return False

def ctrl_q_at(x, y):
   global drop_running

   pyautogui.moveTo(x, y, duration=DROP_MOVE_TIME)

   if sleep_check_cancel(DROP_AFTER_MOVE):
       return False

   keyboard.press("ctrl")

   if sleep_check_cancel(CTRL_HOLD):
       keyboard.release("ctrl")
       return False

   keyboard.press("q")

   if sleep_check_cancel(Q_HOLD):
       keyboard.release("q")
       keyboard.release("ctrl")
       return False

   keyboard.release("q")
   time.sleep(0.002)
   keyboard.release("ctrl")

   if sleep_check_cancel(DROP_AFTER_Q):
       return False

   return True

def drop_system():
   global drop_running

   print("Ctrl+Q sistemi başladı.")

   time.sleep(0.15)

   for x, y in drop_coords:
       if not drop_running:
           print("Ctrl+Q sistemi kapatıldı.")
           return

       if not ctrl_q_at(x, y):
           print("Ctrl+Q sistemi kapatıldı.")
           return

   drop_running = False
   print("Ctrl+Q sistemi bitti.")

while True:
   if keyboard.is_pressed(","):
       print("Program kapatıldı.")
       break

   if keyboard.is_pressed("."):
       craft_once()

       while keyboard.is_pressed("."):
           time.sleep(0.05)

   if keyboard.is_pressed("-"):
       while keyboard.is_pressed("-"):
           time.sleep(0.02)

       if drop_running:
           drop_running = False
           print("Ctrl+Q sistemi kapatılıyor.")
       else:
           drop_running = True
           drop_system()

   time.sleep(0.005)