Register for your free account! | Forgot your password?

Go Back   elitepvpers > Popular Games > Diablo 4
You last visited: Today at 06:53

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Tool] Auto Key Presser for Diablo IV - Automated skill usage and health monitoring

Discussion on [Tool] Auto Key Presser for Diablo IV - Automated skill usage and health monitoring within the Diablo 4 forum part of the Popular Games category.

Reply
 
Old 07/27/2023, 20:10   #16
 
elite*gold: 0
Join Date: Aug 2020
Posts: 4
Received Thanks: 0
Dios, esto es de basico, aca dejo la mejora de ese codigo malo que da errores:

error 1

import cv2
import numpy as np
import tkinter as tk

sino tiene instalado esto no va a dar lo mejor segundo el codigo lo he revisado y es una caca.

en terminal instalar esto:

pip install numpy
pip install opencv-python


Quote:
import tkinter as tk
from tkinter import messagebox, filedialog
import cv2
import numpy as np
import pyautogui
import threading
import time
import keyboard
from PIL import Image

class AutoKeyPresser(tk.Tk):
def __init__(self):
super().__init__()

# Configuración de la ventana principal
self.title("Auto Key Presser - Gamer Edition")
self.geometry("400x700")
self.configure(bg="#2c2c2c")

# Variables
self.key_to_press = [tk.StringVar(self) for _ in range(5)]
self.frequency = [tk.DoubleVar(self) for _ in range(5)]
self.hp_key = tk.StringVar(self)
self.hp_level = tk.DoubleVar(self, value=80)
self.threads = []

# Widgets
self.create_widgets()

# Eventos de teclado
keyboard.add_hotkey('F1', self.set_hp_bar_start)
keyboard.add_hotkey('F2', self.set_hp_bar_end)
keyboard.add_hotkey('F3', self.toggle_script)

self.should_press = threading.Event()

self.hp_bar_x1 = None
self.hp_bar_y1 = None
self.hp_bar_x2 = None
self.hp_bar_y2 = None

def create_widgets(self):
title_label = tk.Label(self, text="Auto Key Presser", bg="#2c2c2c", fg="white", font=("Arial", 18))
title_label.pack(pady=10)

for i in range(5):
tk.Label(self, text=f"Key to Press {i+1}:", bg="#2c2c2c", fg="white").pack(pady=5)
entry = tk.Entry(self, textvariable=self.key_to_press[i])
entry.pack(pady=5)

tk.Label(self, text=f"Frequency {i+1} (seconds):", bg="#2c2c2c", fg="white").pack(pady=5)
entry = tk.Entry(self, textvariable=self.frequency[i])
entry.pack(pady=5)

tk.Label(self, text="HP Key:", bg="#2c2c2c", fg="white").pack(pady=5)
entry = tk.Entry(self, textvariable=self.hp_key)
entry.pack(pady=5)

tk.Label(self, text="HP Bar Image Similarity:", bg="#2c2c2c", fg="white").pack(pady=5)
self.hp_scale = tk.Scale(self, from_=0, to=100, length=300, orient=tk.HORIZONTAL,
variable=self.hp_level, resolution=1, sliderlength=30,
troughcolor='gray', sliderrelief='raised')
self.hp_scale.pack(pady=5)

instructions_label = tk.Label(self, text="To set up the HP bar region, go to your game window and:\n"
"Press F1 at the start of the HP bar.\n"
"Press F2 at the end of the HP bar.", bg="#2c2c2c", fg="white")
instructions_label.pack(pady=15)

self.monitor_hp = tk.BooleanVar(self)
self.hp_checkbox = tk.Checkbutton(self, text="Monitor HP", variable=self.monitor_hp, bg="#2c2c2c", fg="white")
self.hp_checkbox.pack(pady=10)

load_image_btn = tk.Button(self, text="Cargar imagen de referencia", command=self.load_reference_image, bg="#4c4c4c", fg="white")
load_image_btn.pack(pady=10)

start_button = tk.Button(self, text="Start", command=self.start, bg="#4c4c4c", fg="white")
start_button.pack(pady=5)

stop_button = tk.Button(self, text="Stop", command=self.stop, bg="#4c4c4c", fg="white")
stop_button.pack(pady=5)

def load_reference_image(self):
filepath = filedialog.askopenfilename(title="Selecciona una imagen de referencia",
filetypes=[("PNG files", "*.png"), ("JPEG files", "*.jpg"), ("All files", "*.*")])
if not filepath:
return # El usuario canceló la selección

try:
self.gray_bar_reference = cv2.imread(filepath)
self.reference_height, self.reference_width = self.gray_bar_reference.shape[:2]
messagebox.showinfo("Éxito", "Imagen de referencia cargada exitosamente.")
except Exception as e:
messagebox.showerror("Error", f"No se pudo cargar la imagen de referencia. Error: {str(e)}")

def toggle_script(self):
if self.should_press.is_set():
self.stop()
else:
self.start()

def start(self):
# Validación de las entradas
for i in range(5):
key = self.key_to_press[i].get()
frequency = self.frequency[i].get()

# Verificar si la tecla es válida y si la frecuencia es un número positivo
if not key or frequency <= 0:
messagebox.showerror("Error", f"Por favor, proporciona una tecla válida y una frecuencia positiva para la entrada {i+1}.")
return

# Si todo está en orden, desactivar las entradas y comenzar el proceso de pulsación
self.start_pressing()

# Comenzar el monitoreo de HP si está habilitado
if self.monitor_hp.get():
self.scan_full_hp_bar(20)
hp_monitor_thread = threading.Thread(target=self.monitor_hp_and_press_ key)
hp_monitor_thread.start()

messagebox.showinfo("Iniciado", "La pulsación automática de teclas ha comenzado.")

def start_pressing(self):
self.should_press.set()
for i in range(5):
t = threading.Thread(target=self.press_key, args=(i,))
t.start()
self.threads.append(t)

def press_key(self, index):
while self.should_press.is_set():
pyautogui.press(self.key_to_press[index].get())
time.sleep(self.frequency[index].get())

def monitor_hp_and_press_key(self):
while self.should_press.is_set():
hp_percentage = self.get_hp_percentage()
scaled_hp_percentage = self.scale_percentage(hp_percentage)
print(f'Current HP similarity: {scaled_hp_percentage}%')
if scaled_hp_percentage is not None and scaled_hp_percentage < self.hp_level.get():
pyautogui.press(self.hp_key.get())
time.sleep(1)
time.sleep(0.1)

def stop(self):
for t in self.threads:
t.join()
self.should_press.clear()
self.threads = []
messagebox.showinfo("Stopped", "Key pressing has stopped.")

def set_hp_bar_start(self):
x, y = pyautogui.position()
self.hp_bar_x1 = x
self.hp_bar_y1 = y
messagebox.showinfo("Info", f"Start point of HP bar set to: {x}, {y}")

def set_hp_bar_end(self):
x, y = pyautogui.position()
if x < self.hp_bar_x1:
self.hp_bar_x1, x = x, self.hp_bar_x1
if y < self.hp_bar_y1:
self.hp_bar_y1, y = y, self.hp_bar_y1
self.hp_bar_x2 = x
self.hp_bar_y2 = y
messagebox.showinfo("Info", f"End point of HP bar set to: {x}, {y}")

def scan_full_hp_bar(self, duration):
print("Scanning for full HP bar color range...")
end_time = time.time() + duration
frames = []
while time.time() < end_time:
screenshot = pyautogui.screenshot()
hp_bar_region = screenshot.crop((self.hp_bar_x1, self.hp_bar_y1, self.hp_bar_x2, self.hp_bar_y2))
frames.append(np.array(hp_bar_region))
time.sleep(1)
self.full_bar_reference = np.median(frames, axis=0).astype(np.uint8)
print("Full HP bar color range scan completed.")

def get_hp_percentage(self):
hp_bar_pixels = self.capture_hp_bar()
result = cv2.matchTemplate(self.gray_bar_reference, hp_bar_pixels, cv2.TM_CCOEFF_NORMED)
_, max_val, _, _ = cv2.minMaxLoc(result)
return max_val * 100

def capture_hp_bar(self):
screenshot = pyautogui.screenshot()
hp_bar_region = screenshot.crop((self.hp_bar_x1, self.hp_bar_y1, self.hp_bar_x2, self.hp_bar_y2))
hp_bar_region_resized = hp_bar_region.resize((self.reference_width, self.reference_height), Image.ANTIALIAS)
return np.array(hp_bar_region_resized)

def scale_percentage(self, value):
old_min, old_max = -20, 27
new_min, new_max = 0, 100
old_range = old_max - old_min
new_range = new_max - new_min
scaled_value = (((value - old_min) * new_range) / old_range) + new_min
return scaled_value

def run(self):
self.protocol("WM_DELETE_WINDOW", self.close_window)
super().mainloop()

def close_window(self):
self.stop()
self.destroy()

if __name__ == "__main__":
app = AutoKeyPresser()
app.run()
joseroberto19 is offline  
Old 07/28/2023, 14:28   #17
 
elite*gold: 0
Join Date: Jul 2023
Posts: 11
Received Thanks: 5
Wink

Quote:
Originally Posted by joseroberto19 View Post
Dios, esto es de basico, aca dejo la mejora de ese codigo malo que da errores:

error 1

import cv2
import numpy as np
import tkinter as tk

sino tiene instalado esto no va a dar lo mejor segundo el codigo lo he revisado y es una caca.

en terminal instalar esto:

pip install numpy
pip install opencv-python
Let's break apart your changes:
1)I didn't care much for the design, it is a practical tool that isn't limited to diablo4.
2)I had a version with an option to load a reference png but decided that a user who would want to tinker with it will know how.
3)You have some unused imports that would complicate dependencies.
4)My version has the stop function that joins all threads before stopping the key pressing, which might make it more stable. Yours, however, doesn't have such functionality, which might cause some issues if a thread is running when a stop is called.
5)Validation is a great addition. I was lazy.

Functionality-wise, this is the same script. No errors when used as instructed.
Nice changes, but anyone can run "improve my code and add Spanish" on ChatGPT
PeachBlack101 is offline  
Old 07/29/2023, 20:07   #18
 
Missmodd's Avatar
 
elite*gold: 0
Join Date: Jul 2009
Posts: 305
Received Thanks: 129
Quote:
Originally Posted by PeachBlack101 View Post
I'm not using ahk, it's pure python with no game memory reading which less likely be detected. Maybe later they will implement an anti rapid screenshot check. So far wasn't detected.
Just need to be careful, the Warden will run a scan on all the process on your rig if it suspects something fishy going on.

The Warden passes that info, and it gets looked at. Just remember, and 3rd party tool can result in a ban.

Maybe try and obfuscate your exe or file and or even hide it from being seen in the process tree.
Missmodd is offline  
Old 07/29/2023, 20:15   #19
 
elite*gold: 0
Join Date: Aug 2020
Posts: 4
Received Thanks: 0
lo he mejorado y si gracias a ChatGPT pero recuerda solo te ayuda no es que hace todo por ti



te he dado las gracias
joseroberto19 is offline  
Old 08/01/2023, 12:57   #20
 
elite*gold: 0
Join Date: Jul 2023
Posts: 11
Received Thanks: 5
Quote:
Originally Posted by Missmodd View Post
Just need to be careful, the Warden will run a scan on all the process on your rig if it suspects something fishy going on.

The Warden passes that info, and it gets looked at. Just remember, and 3rd party tool can result in a ban.

Maybe try and obfuscate your exe or file and or even hide it from being seen in the process tree.
It was noted before that it can be detected if the screen capture; otherwise, the name can be changed and recompiled. The program doesn't read from game memory or touch game files. One would argue that taking rapid screenshots doesn't affect the game and most functionality of the tool can be achieved with any mouse/keyboard macro.
I would recommend renaming the file. Work around the Warden could be also running your cheats on a VM and sending the inputs to the main machine.

Quote:
Originally Posted by joseroberto19 View Post
lo he mejorado y si gracias a ChatGPT pero recuerda solo te ayuda no es que hace todo por ti



te he dado las gracias
Thanks. Noted some ideas. will add it later this week when exams are over
PeachBlack101 is offline  
Thanks
1 User
Old 08/01/2023, 22:29   #21
 
elite*gold: 0
Join Date: Aug 2023
Posts: 2
Received Thanks: 1
Quote:
Originally Posted by PeachBlack101 View Post
Hello fellow Diablo IV enthusiasts,

I'm excited to share a tool I've been working on - an Auto Key Presser specifically tailored for Diablo IV!

This Python script automates some key aspects of gameplay to give you an edge in your Diablo IV experience. Specifically, it automates skill usage and health monitoring.

Features:

Automated Key Pressing: Set up to five keys that will be pressed at specified intervals. This is ideal for automating skill usage that has cooldowns.
Health Monitoring and Auto Healing: The script monitors your health bar and automatically presses a healing key when health drops below a certain threshold. Never miss a critical heal again!
Setup is simple. Run the script, and a GUI will appear where you can set your skill keys, their frequencies, your healing key, and your desired health threshold.

Remember to adjust the coordinates for your game window's health bar in the script to match your game setup, and you'll also need to provide an image of an empty health bar.

It's important to note that this tool is specifically designed for Diablo IV, and may not be compatible with other games without some adjustments. The script uses a similarity comparison between your current health bar and an image of an empty health bar, so changes in game's health bar design or color might affect the script's performance.

I've been using this tool to enhance my Diablo IV experience and I think you'll find it helpful too. Feel free to check it out, give it a try, and let me know your feedback.

The tool is available on my GitHub . Happy gaming!

Best,
PeachBlack
Can you provide information on how to run this code on a Windows 10 PC, step by step?
MJT03 is offline  
Thanks
1 User
Old 08/07/2023, 00:14   #22
 
jaren's Avatar
 
elite*gold: 8
Join Date: Apr 2007
Posts: 426
Received Thanks: 111
Thanks for your contribution. Don't really care to use it right now for D4 but looking forward to looking at the code for my learning. Thanks a bunch!
jaren is offline  
Thanks
1 User
Old 08/09/2023, 17:35   #23
 
elite*gold: 0
Join Date: Dec 2010
Posts: 12
Received Thanks: 1
Do not use automation. Friend got banned within 2 hours of using something similar to this. BEWARE
Crashproofcodez is offline  
Thanks
1 User
Old 08/10/2023, 18:46   #24
 
elite*gold: 0
Join Date: Aug 2020
Posts: 4
Received Thanks: 0
el que he creado yo tiene un algoritmo que cambia cada segundo para que no se pueda detectar en los proceso. y no se pueda injetar
joseroberto19 is offline  
Old 08/10/2023, 20:17   #25
 
elite*gold: 0
Join Date: Jul 2023
Posts: 11
Received Thanks: 5
Quote:
Originally Posted by MJT03 View Post
Can you provide information on how to run this code on a Windows 10 PC, step by step?
1)Download files from git.
2)Install requirements
2.1) Open CMD (you can type "cmd" in the file path input bar to start CMD from app path location).
2.2) type "pip install requirements.txt"
3) type "python autosomal.py" (it could be python3, depending on the version you have installed. Try the second if the first didn't work.)
4) point mouse o the top of hp bar and press f1. Move to bottom of hp bar and press f2.
5)Enter the keys for your skills and press delay. Enter the heal key and set heal threshold.
6)Press start when Hp bar is full and wait 20 seconds with full hp so health bar color range could be scanned.
If you get around 94-100 reading in CMD window when on full HP, your doing good.

Have fun gaming.

Quote:
Originally Posted by jaren View Post
Thanks for your contribution. Don't really care to use it right now for D4 but looking forward to looking at the code for my learning. Thanks a bunch!
Note that it easily modifiable for any game using HP bar and skill keys. POE for example.
Glade my code could be of use ��

Quote:
Originally Posted by Crashproofcodez View Post
Do not use automation. Friend got banned within 2 hours of using something similar to this. BEWARE
Was your friend running python based app or ahk?
PeachBlack101 is offline  
Old 12/08/2023, 11:31   #26
 
kaikai89's Avatar
 
elite*gold: 0
Join Date: May 2009
Posts: 66
Received Thanks: 7
why you not use the legal auto press key from blizzard/diablo ? its build in in the game
kaikai89 is offline  
Old 01/12/2024, 14:13   #27
 
elite*gold: 0
Join Date: Jan 2024
Posts: 1
Received Thanks: 0
Any chance to add controller support?
patrikstevens is offline  
Old 02/15/2024, 23:48   #28

 
Cabras's Avatar
 
elite*gold: 290
Join Date: Sep 2023
Posts: 5
Received Thanks: 23
Great work
Cabras is offline  
Reply


Similar Threads Similar Threads
Auto key presser (Better than F-Tool) compatible with flyff universe (totally free)
09/27/2022 - Flyff Hacks, Bots, Cheats, Exploits & Macros - 1 Replies
Hello people! Here is a program from another game, but it is 100% compatible with the new version of the game Flyff (Universe) https://i.epvpimg.com/Alnieab.jpg https://epvpimg.com/Alnieab https://i.epvpimg.com/c0Fbcab.jpg https://epvpimg.com/c0Fbcab This program is trained both for the use of numbers (1-0) and function keys (F1-F12) Why do I say that it is better than F-Tool by Yami? Because you can assign up to 12 actions to this program at the same time per window, and open the...
Auto Key Presser + Auto Ress + macro bot
01/21/2010 - SRO Hacks, Bots, Cheats & Exploits - 1 Replies
Edit...
Where to Find a Auto skill presser
04/08/2009 - SRO Private Server - 1 Replies
Where can i find one that's safe to use, anyone know. thx



All times are GMT +2. The time now is 06:53.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.