Çözüldü Visual Studio Code'daki kod sadece F5 ile çalışıyor

Bu konu çözüldü olarak işaretlenmiştir. Çözülmediğini düşünüyorsanız konuyu rapor edebilirsiniz.

Crusth

Hectopat
Katılım
6 Şubat 2022
Mesajlar
91
Yer
istanbul
Daha fazla  
Sistem Özellikleri
Anakart: GTX-1060 6GB
Ram: 16GB-ddr3 ram
İşlemci: intel xeon e3 1240 v3
Anakart: GIGABYTE H87-HD3
Cinsiyet
Erkek
Merhaba arkadaşlar yazdığım kodu çalıştırıyorken sadece F5 tuşuna basarak çalıştırıyorum ama bunu sağ yukarıdaki başlatma butonuna basınca çalıştıramıyorum. Bunun nedeni nedir acaba?

Python:
import tkinter as tk.
import pyautogui.
import keyboard.
import cv2.
import numpy as np.
import os.
from PIL import Image, ImageTk.
import time.
pyautogui.PAUSE = 0.0
pyautogui.FAILSAFE = False.
stop_flag = False.
def stop_program(e):
 global stop_flag.
 if e.name == 'right shift' and e.event_type == 'down':
 stop_flag = True.
def find_and_click_image(image_path, region=None, retries=5):
 """
 Görseli bulur ve tıklar. Eğer görsel bulunamazsa imleç hareket etmez.
 """
 if not os.path.exists(image_path):
 print(f"Dosya bulunamadı: {image_path}")
 return False.
 screen = np.array(pyautogui.screenshot(region=region))
 screen = cv2.cvtColor(screen, cv2.COLOR_RGB2BGR)
 template = cv2.imread(image_path)
 if template is None:
 print(f"Dosya açılamadı: {image_path}")
 return False.
 template_gray = cv2.cvtColor(template, cv2.COLOR_BGR2GRAY)
 screen_gray = cv2.cvtColor(screen, cv2.COLOR_BGR2GRAY)
 result = cv2.matchTemplate(screen_gray, template_gray, cv2.TM_CCOEFF_NORMED)
 _, max_val, _, max_loc = cv2.minMaxLoc(result)
 if max_val >= 0.8:
 top_left = max_loc.
 h, w = template_gray.shape
 target_x, target_y = top_left[0] + w // 2 + (region[0] if region else 0), top_left[1] + h // 2 + (region[1] if region else 0)
 for attempt in range(retries):
 pyautogui.moveTo(target_x, target_y, duration=0.02)
 pyautogui.click(interval=0.05)
 time.sleep(0.1)
 # Tıklamanın başarıyla gerçekleştiğini varsayıyoruz.
 return True.
 print(f"Görsel bulunamadı veya tıklama başarısız: {image_path}")
 return False.
def start_execution(character):
 """
 Seçilen karakterin görselini arar, bulursa tıklar ve kilitleme işlemini başlatır.
 """
 global stop_flag.
 stop_flag = False.
 region = (40, 300, 1100, 890) # Ekranda kontrol edilecek bölge.
 while not stop_flag:
 if find_and_click_image(f"{character}.png", region=region):
 print(f"{character.capitalize()} bulundu ve tıklanıldı.")
 status_label.config(text=f"{character.capitalize()} Instalock atılıyor...")
 if find_and_click_image("kilitle.png", region=region):
 print("Kilitle bulundu ve tıklanıldı.")
 status_label.config(text="Kilitle tıklanıyor...")
 break.
 else:
 print("Kilitle görseli bulunamadı.")
 status_label.config(text="Kilitle aranıyor...")
 else:
 print(f"{character.capitalize()} görseli bulunamadı.")
 status_label.config(text=f"{character.capitalize()} aranıyor...")
 root.update()
 if stop_flag:
 status_label.config(text=f"{character.capitalize()} instalock durduruldu.")
 break.
root = tk.Tk()
root.title("İnstalocker")
root.configure(bg="gray")
root.attributes('-topmost', True)
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
window_width = 320.
window_height = 300.
x_position = screen_width - window_width - 50.
y_position = screen_height - window_height - 50.
root.geometry(f"{window_width}x{window_height}+{x_position}+{y_position}")
root.resizable(False, False)
canvas = tk.Canvas(root, width=window_width, height=window_height)
canvas.pack(fill="both", expand=True)
background_img = Image.open("arkaplan.png").resize((320, 300))
background_img_tk = ImageTk.PhotoImage(background_img)
canvas.create_image(0, 0, image=background_img_tk, anchor="nw")
def load_image(image_name):
 img = Image.open(image_name).resize((80, 80))
 return img.
reyna_img = load_image("reyna.png")
jett_img = load_image("jett.png")
neon_img = load_image("neon.png")
raze_img = load_image("raze.png")
phoenix_img = load_image("phoenix.png")
iso_img = load_image("iso.png")
reyna_img_tk = ImageTk.PhotoImage(reyna_img)
jett_img_tk = ImageTk.PhotoImage(jett_img)
neon_img_tk = ImageTk.PhotoImage(neon_img)
raze_img_tk = ImageTk.PhotoImage(raze_img)
phoenix_img_tk = ImageTk.PhotoImage(phoenix_img)
iso_img_tk = ImageTk.PhotoImage(iso_img)
canvas.create_window(60, 50, anchor="center", window=tk.Button(root, image=reyna_img_tk, command=lambda: start_execution("reyna")))
canvas.create_window(160, 50, anchor="center", window=tk.Button(root, image=jett_img_tk, command=lambda: start_execution("jett")))
canvas.create_window(260, 50, anchor="center", window=tk.Button(root, image=neon_img_tk, command=lambda: start_execution("neon")))
canvas.create_window(60, 150, anchor="center", window=tk.Button(root, image=raze_img_tk, command=lambda: start_execution("raze")))
canvas.create_window(160, 150, anchor="center", window=tk.Button(root, image=phoenix_img_tk, command=lambda: start_execution("phoenix")))
canvas.create_window(260, 150, anchor="center", window=tk.Button(root, image=iso_img_tk, command=lambda: start_execution("iso")))
status_label = tk.Label(root, text="Durdurmak için sağ shift basın", bg="dim gray")
canvas.create_window(160, 245, anchor="center", window=status_label)
keyboard.on_press(stop_program)
root.mainloop()

Merhaba arkadaşlar yazdığım kodu çalıştırıyorken sadece F5 tuşuna basarak çalıştırıyorum ama bunu sağ yukarıdaki başlatma butonuna basınca çalıştıramıyorum. Bunun nedeni nedir acaba?

Python:
import tkinter as tk.
import pyautogui.
import keyboard.
import cv2.
import numpy as np.
import os.
from PIL import Image, ImageTk.
import time.
pyautogui.PAUSE = 0.0
pyautogui.FAILSAFE = False.
stop_flag = False.
def stop_program(e):
 global stop_flag.
 if e.name == 'right shift' and e.event_type == 'down':
 stop_flag = True.
def find_and_click_image(image_path, region=None, retries=5):
 """
 Görseli bulur ve tıklar. Eğer görsel bulunamazsa imleç hareket etmez.
 """
 if not os.path.exists(image_path):
 print(f"Dosya bulunamadı: {image_path}")
 return False.
 screen = np.array(pyautogui.screenshot(region=region))
 screen = cv2.cvtColor(screen, cv2.COLOR_RGB2BGR)
 template = cv2.imread(image_path)
 if template is None:
 print(f"Dosya açılamadı: {image_path}")
 return False.
 template_gray = cv2.cvtColor(template, cv2.COLOR_BGR2GRAY)
 screen_gray = cv2.cvtColor(screen, cv2.COLOR_BGR2GRAY)
 result = cv2.matchTemplate(screen_gray, template_gray, cv2.TM_CCOEFF_NORMED)
 _, max_val, _, max_loc = cv2.minMaxLoc(result)
 if max_val >= 0.8:
 top_left = max_loc.
 h, w = template_gray.shape
 target_x, target_y = top_left[0] + w // 2 + (region[0] if region else 0), top_left[1] + h // 2 + (region[1] if region else 0)
 for attempt in range(retries):
 pyautogui.moveTo(target_x, target_y, duration=0.02)
 pyautogui.click(interval=0.05)
 time.sleep(0.1)
 # Tıklamanın başarıyla gerçekleştiğini varsayıyoruz.
 return True.
 print(f"Görsel bulunamadı veya tıklama başarısız: {image_path}")
 return False.
def start_execution(character):
 """
 Seçilen karakterin görselini arar, bulursa tıklar ve kilitleme işlemini başlatır.
 """
 global stop_flag.
 stop_flag = False.
 region = (40, 300, 1100, 890) # Ekranda kontrol edilecek bölge.
 while not stop_flag:
 if find_and_click_image(f"{character}.png", region=region):
 print(f"{character.capitalize()} bulundu ve tıklanıldı.")
 status_label.config(text=f"{character.capitalize()} Instalock atılıyor...")
 if find_and_click_image("kilitle.png", region=region):
 print("Kilitle bulundu ve tıklanıldı.")
 status_label.config(text="Kilitle tıklanıyor...")
 break.
 else:
 print("Kilitle görseli bulunamadı.")
 status_label.config(text="Kilitle aranıyor...")
 else:
 print(f"{character.capitalize()} görseli bulunamadı.")
 status_label.config(text=f"{character.capitalize()} aranıyor...")
 root.update()
 if stop_flag:
 status_label.config(text=f"{character.capitalize()} instalock durduruldu.")
 break.
root = tk.Tk()
root.title("İnstalocker")
root.configure(bg="gray")
root.attributes('-topmost', True)
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
window_width = 320.
window_height = 300.
x_position = screen_width - window_width - 50.
y_position = screen_height - window_height - 50.
root.geometry(f"{window_width}x{window_height}+{x_position}+{y_position}")
root.resizable(False, False)
canvas = tk.Canvas(root, width=window_width, height=window_height)
canvas.pack(fill="both", expand=True)
background_img = Image.open("arkaplan.png").resize((320, 300))
background_img_tk = ImageTk.PhotoImage(background_img)
canvas.create_image(0, 0, image=background_img_tk, anchor="nw")
def load_image(image_name):
 img = Image.open(image_name).resize((80, 80))
 return img.
reyna_img = load_image("reyna.png")
jett_img = load_image("jett.png")
neon_img = load_image("neon.png")
raze_img = load_image("raze.png")
phoenix_img = load_image("phoenix.png")
iso_img = load_image("iso.png")
reyna_img_tk = ImageTk.PhotoImage(reyna_img)
jett_img_tk = ImageTk.PhotoImage(jett_img)
neon_img_tk = ImageTk.PhotoImage(neon_img)
raze_img_tk = ImageTk.PhotoImage(raze_img)
phoenix_img_tk = ImageTk.PhotoImage(phoenix_img)
iso_img_tk = ImageTk.PhotoImage(iso_img)
canvas.create_window(60, 50, anchor="center", window=tk.Button(root, image=reyna_img_tk, command=lambda: start_execution("reyna")))
canvas.create_window(160, 50, anchor="center", window=tk.Button(root, image=jett_img_tk, command=lambda: start_execution("jett")))
canvas.create_window(260, 50, anchor="center", window=tk.Button(root, image=neon_img_tk, command=lambda: start_execution("neon")))
canvas.create_window(60, 150, anchor="center", window=tk.Button(root, image=raze_img_tk, command=lambda: start_execution("raze")))
canvas.create_window(160, 150, anchor="center", window=tk.Button(root, image=phoenix_img_tk, command=lambda: start_execution("phoenix")))
canvas.create_window(260, 150, anchor="center", window=tk.Button(root, image=iso_img_tk, command=lambda: start_execution("iso")))
status_label = tk.Label(root, text="Durdurmak için sağ shift basın", bg="dim gray")
canvas.create_window(160, 245, anchor="center", window=status_label)
keyboard.on_press(stop_program)
root.mainloop()

1735840147146.png


Code runner eklentisini kurarak sorunumu çözdüm.
 
Son düzenleyen: Moderatör:
Zaten sorunu çözmüşsünüz fakat böyle araçların kullanımı tarafınıza fena küfür yedirtebilir. Ban riski olmasa da yine de pek etik değil. Kendim de kullandığımdan biliyorum fena küfür yiyorsunuz. Bayağıdır şu instalockeri kullanıyorum ve işimi görüyor Berkwe/Valorant-instalocker/
 

Bu konuyu görüntüleyen kullanıcılar

Technopat Haberler

Geri
Yukarı