Advertisement
j100tm

Untitled

Dec 19th, 2024
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 7.27 KB | None | 0 0
  1. import customtkinter as ctk
  2. import keyboard
  3. import mouse
  4. import screeninfo
  5. import configparser
  6. import os
  7. import time
  8. import threading
  9. import ctypes
  10. import ast
  11. import json as jsond  # json
  12. import time  # sleep before exit
  13. import binascii  # hex encoding
  14. import platform  # check platform
  15. import subprocess  # needed for mac device
  16. from datetime import datetime
  17.  
  18. # Setting up config file
  19. aimCheck = False
  20. xValue = 0
  21. yValue = 0
  22. leftValue = 0
  23. delayValue = 1
  24. enabled = False
  25.  
  26. # Define a list of valid keys
  27. valid_keys = ["1", "90", "5678", "1234"]  # Add any valid keys here
  28.  
  29. # Create config file if it does not exist
  30. if not os.path.isfile('config.txt'):
  31.     print('config.txt file not found. Creating new one...')
  32.     config = configparser.ConfigParser()
  33.     config['hotkey'] = {'hotkey_on': 'f1', 'hotkey_off': 'f2'}
  34.     config['loadouts'] = {}
  35.     with open('config.txt', 'w') as configfile:
  36.         config.write(configfile)
  37.     input('Press any key to exit...')
  38.     exit()
  39. else:
  40.     config = configparser.ConfigParser()
  41.     config.read('config.txt')
  42.  
  43. # CustomTkinter Settings
  44. ctk.set_appearance_mode("System")
  45. ctk.set_default_color_theme("blue")
  46.  
  47. # Recoil Macro App Main Window
  48. class RecoilMacroApp(ctk.CTk):
  49.     def __init__(self):
  50.         super().__init__()
  51.         self.title("HX Recoil")
  52.         self.geometry('500x600')
  53.        
  54.         # Initialize variables
  55.         self.aimCheck = False
  56.         self.enabled = False
  57.         self.xValue = 0
  58.         self.leftValue = 0
  59.         self.yValue = 0
  60.         self.delayValue = 1
  61.  
  62.         # Fading background color variables
  63.         self.bg_fade_state = 0  # Start with first color
  64.         self.bg_fade_interval = 2000  # Time in ms between color change
  65.         self.bg_colors = ["#FF8C8C", "#FF4C4C", "#FF0000", "#FF69B4"]  # Colors to fade between
  66.  
  67.         # Main Title Label
  68.         self.title_label = ctk.CTkLabel(self, text="HX Recoil", text_color="white", font=("Arial", 20, "bold"))
  69.         self.title_label.pack(pady=20)
  70.  
  71.         # UI Elements
  72.         self.aimCheckButton = ctk.CTkButton(self, text="Aim Check Off", command=self.toggleAimCheck, fg_color="#FF4C4C", hover_color="#FF2A2A")
  73.         self.aimCheckButton.pack(pady=10)
  74.  
  75.         # X (Right) Control Slider and Value
  76.         self.xLabel = ctk.CTkLabel(self, text='X Control Value (Right)', text_color="white")
  77.         self.xLabel.pack(pady=5)
  78.         self.xSlider = ctk.CTkSlider(self, from_=0, to=40, number_of_steps=40, command=self.update_x_value, fg_color="#FF4C4C", progress_color="#FF0000")
  79.         self.xSlider.pack(pady=5)
  80.         self.xValueLabel = ctk.CTkLabel(self, text="X Value: 20", text_color="white")
  81.         self.xValueLabel.pack(pady=5)
  82.  
  83.         # Left Axis (Left) Control Slider and Value
  84.         self.leftLabel = ctk.CTkLabel(self, text='Left Control Value (Left)', text_color="white")
  85.         self.leftLabel.pack(pady=5)
  86.         self.leftSlider = ctk.CTkSlider(self, from_=-40, to=0, number_of_steps=40, command=self.update_left_value, fg_color="#FF4C4C", progress_color="#FF0000")
  87.         self.leftSlider.pack(pady=5)
  88.         self.leftValueLabel = ctk.CTkLabel(self, text="Left Value: 20", text_color="white")
  89.         self.leftValueLabel.pack(pady=5)
  90.  
  91.         # Y (Down) Control Slider and Value
  92.         self.yLabel = ctk.CTkLabel(self, text='Y Control Value (Down)', text_color="white")
  93.         self.yLabel.pack(pady=5)
  94.         self.ySlider = ctk.CTkSlider(self, from_=0, to=40, number_of_steps=40, command=self.update_y_value, fg_color="#FF4C4C", progress_color="#FF0000")
  95.         self.ySlider.pack(pady=5)
  96.         self.yValueLabel = ctk.CTkLabel(self, text="Y Value: 20", text_color="white")
  97.         self.yValueLabel.pack(pady=5)
  98.  
  99.         # Set Button
  100.         self.setButton = ctk.CTkButton(self, text="Set Values", command=self.setValues, fg_color="#FF4C4C", hover_color="#FF2A2A")
  101.         self.setButton.pack(pady=10)
  102.  
  103.         # Loadout Entry
  104.         self.loadoutNameEntry = ctk.CTkEntry(self, placeholder_text="Enter Loadout Name", fg_color="#FF4C4C", text_color="white")
  105.         self.loadoutNameEntry.pack(pady=10)
  106.  
  107.         # Save and Load Buttons
  108.         self.saveButton = ctk.CTkButton(self, text="Save Loadout", command=self.saveLoadout, fg_color="#FF4C4C", hover_color="#FF2A2A")
  109.         self.saveButton.pack(pady=5)
  110.         self.loadButton = ctk.CTkButton(self, text="Load Loadout", command=self.loadLoadout, fg_color="#FF4C4C", hover_color="#FF2A2A")
  111.         self.loadButton.pack(pady=5)
  112.  
  113.         # Hotkeys for toggling
  114.         keyboard.add_hotkey("f1", self.enableMacro)
  115.         keyboard.add_hotkey("f2", self.disableMacro)
  116.  
  117.         # Start macro thread
  118.         self.macro_thread = threading.Thread(target=self.macroTask)
  119.         self.macro_thread.daemon = True
  120.         self.macro_thread.start()
  121.  
  122.     def setValues(self):
  123.         self.xValue = min(int(self.xSlider.get()), 40)
  124.         self.leftValue = max(int(self.leftSlider.get()), -40)
  125.         self.yValue = min(int(self.ySlider.get()), 40)
  126.         print(f"Values set - X: {self.xValue}, Left: {self.leftValue}, Y: {self.yValue}, Delay: {self.delayValue}ms")
  127.  
  128.     def toggleAimCheck(self):
  129.         self.aimCheck = not self.aimCheck
  130.         self.aimCheckButton.configure(text="Aim Check On" if self.aimCheck else "Aim Check Off")
  131.  
  132.     def saveLoadout(self):
  133.         name = self.loadoutNameEntry.get()
  134.         if name:
  135.             config['loadouts'][name] = f'[{self.xValue},{self.leftValue},{self.yValue},{self.delayValue}]'
  136.             with open('config.txt', 'w') as configfile:
  137.                 config.write(configfile)
  138.             print(f"Loadout '{name}' saved!")
  139.  
  140.     def loadLoadout(self):
  141.         name = self.loadoutNameEntry.get()
  142.         if name in config['loadouts']:
  143.             loadout = ast.literal_eval(config['loadouts'][name])
  144.             self.xValue, self.leftValue, self.yValue, self.delayValue = loadout
  145.             self.xSlider.set(self.xValue)
  146.             self.leftSlider.set(self.leftValue)
  147.             self.ySlider.set(self.yValue)
  148.             print(f"Loadout '{name}' loaded!")
  149.  
  150.     def enableMacro(self):
  151.         self.enabled = True
  152.         print("Macro Enabled!")
  153.  
  154.     def disableMacro(self):
  155.         self.enabled = False
  156.         print("Macro Disabled!")
  157.  
  158.     def macroTask(self):
  159.         while True:
  160.             if self.enabled:
  161.                 if self.aimCheck:
  162.                     if ctypes.windll.user32.GetAsyncKeyState(0x01) & 0x8000 and ctypes.windll.user32.GetAsyncKeyState(0x02) & 0x8000:
  163.                         self.moveRel(self.xValue + self.leftValue, self.yValue)
  164.                 else:
  165.                     if ctypes.windll.user32.GetAsyncKeyState(0x01) & 0x8000:
  166.                         self.moveRel(self.xValue + self.leftValue, self.yValue)
  167.             time.sleep(self.delayValue / 1000)
  168.  
  169.     def moveRel(self, x, y):
  170.         ctypes.windll.user32.mouse_event(0x0001, x, y, 0, 0)
  171.  
  172.     def update_x_value(self, value):
  173.         self.xValueLabel.configure(text=f"X Value: {int(float(value))}")
  174.  
  175.     def update_left_value(self, value):
  176.         self.leftValueLabel.configure(text=f"Left Value: {int(float(value))}")
  177.  
  178.     def update_y_value(self, value):
  179.         self.yValueLabel.configure(text=f"Y Value: {int(float(value))}")
  180.  
  181.  
  182. # Launch the application
  183. if __name__ == "__main__":
  184.     app = RecoilMacroApp()
  185.     app.mainloop()
  186.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement