diff --git a/scripts/custom_macro/config.yaml b/scripts/custom_macro/config.yaml index 4022186..59bfc20 100644 --- a/scripts/custom_macro/config.yaml +++ b/scripts/custom_macro/config.yaml @@ -10,5 +10,5 @@ key_stop_script: 'F3' # Look at the pywinauto documentation send_keystrokes() for any advanced keystrokes you may need, such as holding down a key, etc... # ------------------------------ steps: [ - ["e", 1], + ["f", 1, 3], ] \ No newline at end of file diff --git a/scripts/custom_macro/start_custom_macro.py b/scripts/custom_macro/start_custom_macro.py index dbf7e6f..836497a 100644 --- a/scripts/custom_macro/start_custom_macro.py +++ b/scripts/custom_macro/start_custom_macro.py @@ -1,4 +1,5 @@ from pywinauto.application import Application +import random import keyboard import yaml import time @@ -6,18 +7,20 @@ import sys -def run_step(game, actions, sleep_time, stop_flag): +def run_step(game, actions, min_delay, max_delay, stop_flag): """Send keystrokes safely.""" if stop_flag["stop"]: return False + random_delay = random.uniform(1.0, 5.0) + for a in actions: game.send_keystrokes(a) if stop_flag["stop"]: return False - if sleep_time: - time.sleep(sleep_time) + if random_delay: + time.sleep(random_delay) if stop_flag["stop"]: return False @@ -74,8 +77,8 @@ def stop(): n_rotations = 0 while not stop_flag["stop"]: - for actions, delay in steps: - if not run_step(game, actions, delay, stop_flag): + for actions, min_delay, max_delay in steps: + if not run_step(game, actions, min_delay, max_delay, stop_flag): return n_rotations += 1