Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import customtkinter as ctk
- import keyboard
- import mouse
- import screeninfo
- import configparser
- import os
- import time
- import threading
- import ctypes
- import ast
- import json as jsond # json
- import time # sleep before exit
- import binascii # hex encoding
- import platform # check platform
- import subprocess # needed for mac device
- from datetime import datetime
- # Setting up config file
- aimCheck = False
- xValue = 0
- yValue = 0
- leftValue = 0
- delayValue = 1
- enabled = False
- # Define a list of valid keys
- valid_keys = ["1", "90", "5678", "1234"] # Add any valid keys here
- # Create config file if it does not exist
- if not os.path.isfile('config.txt'):
- print('config.txt file not found. Creating new one...')
- config = configparser.ConfigParser()
- config['hotkey'] = {'hotkey_on': 'f1', 'hotkey_off': 'f2'}
- config['loadouts'] = {}
- with open('config.txt', 'w') as configfile:
- config.write(configfile)
- input('Press any key to exit...')
- exit()
- else:
- config = configparser.ConfigParser()
- config.read('config.txt')
- # CustomTkinter Settings
- ctk.set_appearance_mode("System")
- ctk.set_default_color_theme("blue")
- # Recoil Macro App Main Window
- class RecoilMacroApp(ctk.CTk):
- def __init__(self):
- super().__init__()
- self.title("HX Recoil")
- self.geometry('500x600')
- # Initialize variables
- self.aimCheck = False
- self.enabled = False
- self.xValue = 0
- self.leftValue = 0
- self.yValue = 0
- self.delayValue = 1
- # Fading background color variables
- self.bg_fade_state = 0 # Start with first color
- self.bg_fade_interval = 2000 # Time in ms between color change
- self.bg_colors = ["#FF8C8C", "#FF4C4C", "#FF0000", "#FF69B4"] # Colors to fade between
- # Main Title Label
- self.title_label = ctk.CTkLabel(self, text="HX Recoil", text_color="white", font=("Arial", 20, "bold"))
- self.title_label.pack(pady=20)
- # UI Elements
- self.aimCheckButton = ctk.CTkButton(self, text="Aim Check Off", command=self.toggleAimCheck, fg_color="#FF4C4C", hover_color="#FF2A2A")
- self.aimCheckButton.pack(pady=10)
- # X (Right) Control Slider and Value
- self.xLabel = ctk.CTkLabel(self, text='X Control Value (Right)', text_color="white")
- self.xLabel.pack(pady=5)
- self.xSlider = ctk.CTkSlider(self, from_=0, to=40, number_of_steps=40, command=self.update_x_value, fg_color="#FF4C4C", progress_color="#FF0000")
- self.xSlider.pack(pady=5)
- self.xValueLabel = ctk.CTkLabel(self, text="X Value: 20", text_color="white")
- self.xValueLabel.pack(pady=5)
- # Left Axis (Left) Control Slider and Value
- self.leftLabel = ctk.CTkLabel(self, text='Left Control Value (Left)', text_color="white")
- self.leftLabel.pack(pady=5)
- self.leftSlider = ctk.CTkSlider(self, from_=-40, to=0, number_of_steps=40, command=self.update_left_value, fg_color="#FF4C4C", progress_color="#FF0000")
- self.leftSlider.pack(pady=5)
- self.leftValueLabel = ctk.CTkLabel(self, text="Left Value: 20", text_color="white")
- self.leftValueLabel.pack(pady=5)
- # Y (Down) Control Slider and Value
- self.yLabel = ctk.CTkLabel(self, text='Y Control Value (Down)', text_color="white")
- self.yLabel.pack(pady=5)
- self.ySlider = ctk.CTkSlider(self, from_=0, to=40, number_of_steps=40, command=self.update_y_value, fg_color="#FF4C4C", progress_color="#FF0000")
- self.ySlider.pack(pady=5)
- self.yValueLabel = ctk.CTkLabel(self, text="Y Value: 20", text_color="white")
- self.yValueLabel.pack(pady=5)
- # Set Button
- self.setButton = ctk.CTkButton(self, text="Set Values", command=self.setValues, fg_color="#FF4C4C", hover_color="#FF2A2A")
- self.setButton.pack(pady=10)
- # Loadout Entry
- self.loadoutNameEntry = ctk.CTkEntry(self, placeholder_text="Enter Loadout Name", fg_color="#FF4C4C", text_color="white")
- self.loadoutNameEntry.pack(pady=10)
- # Save and Load Buttons
- self.saveButton = ctk.CTkButton(self, text="Save Loadout", command=self.saveLoadout, fg_color="#FF4C4C", hover_color="#FF2A2A")
- self.saveButton.pack(pady=5)
- self.loadButton = ctk.CTkButton(self, text="Load Loadout", command=self.loadLoadout, fg_color="#FF4C4C", hover_color="#FF2A2A")
- self.loadButton.pack(pady=5)
- # Hotkeys for toggling
- keyboard.add_hotkey("f1", self.enableMacro)
- keyboard.add_hotkey("f2", self.disableMacro)
- # Start macro thread
- self.macro_thread = threading.Thread(target=self.macroTask)
- self.macro_thread.daemon = True
- self.macro_thread.start()
- def setValues(self):
- self.xValue = min(int(self.xSlider.get()), 40)
- self.leftValue = max(int(self.leftSlider.get()), -40)
- self.yValue = min(int(self.ySlider.get()), 40)
- print(f"Values set - X: {self.xValue}, Left: {self.leftValue}, Y: {self.yValue}, Delay: {self.delayValue}ms")
- def toggleAimCheck(self):
- self.aimCheck = not self.aimCheck
- self.aimCheckButton.configure(text="Aim Check On" if self.aimCheck else "Aim Check Off")
- def saveLoadout(self):
- name = self.loadoutNameEntry.get()
- if name:
- config['loadouts'][name] = f'[{self.xValue},{self.leftValue},{self.yValue},{self.delayValue}]'
- with open('config.txt', 'w') as configfile:
- config.write(configfile)
- print(f"Loadout '{name}' saved!")
- def loadLoadout(self):
- name = self.loadoutNameEntry.get()
- if name in config['loadouts']:
- loadout = ast.literal_eval(config['loadouts'][name])
- self.xValue, self.leftValue, self.yValue, self.delayValue = loadout
- self.xSlider.set(self.xValue)
- self.leftSlider.set(self.leftValue)
- self.ySlider.set(self.yValue)
- print(f"Loadout '{name}' loaded!")
- def enableMacro(self):
- self.enabled = True
- print("Macro Enabled!")
- def disableMacro(self):
- self.enabled = False
- print("Macro Disabled!")
- def macroTask(self):
- while True:
- if self.enabled:
- if self.aimCheck:
- if ctypes.windll.user32.GetAsyncKeyState(0x01) & 0x8000 and ctypes.windll.user32.GetAsyncKeyState(0x02) & 0x8000:
- self.moveRel(self.xValue + self.leftValue, self.yValue)
- else:
- if ctypes.windll.user32.GetAsyncKeyState(0x01) & 0x8000:
- self.moveRel(self.xValue + self.leftValue, self.yValue)
- time.sleep(self.delayValue / 1000)
- def moveRel(self, x, y):
- ctypes.windll.user32.mouse_event(0x0001, x, y, 0, 0)
- def update_x_value(self, value):
- self.xValueLabel.configure(text=f"X Value: {int(float(value))}")
- def update_left_value(self, value):
- self.leftValueLabel.configure(text=f"Left Value: {int(float(value))}")
- def update_y_value(self, value):
- self.yValueLabel.configure(text=f"Y Value: {int(float(value))}")
- # Launch the application
- if __name__ == "__main__":
- app = RecoilMacroApp()
- app.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement