Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/custom_macro/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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],
]
13 changes: 8 additions & 5 deletions scripts/custom_macro/start_custom_macro.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
from pywinauto.application import Application
import random
import keyboard
import yaml
import time
import os
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

Expand Down Expand Up @@ -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
Expand Down