atbswp
atbswp copied to clipboard
Feature request: Support indented blocks in macro scripts
Checklist
- [x] I use the latest release of atbswp
- [x] The issue is not existing yet
Description
It would nice to be able to have indented blocks in the macro scripts e.g. for loops. I'd rather keep the script clean and use a loop for repetitive actions, but it seems that when reading the script atbswp strips out indents, example script below:
import pyautogui
import time
pyautogui.FAILSAFE = False
iterations = list(range(1, 100))
pyautogui.keyDown('ctrlleft')
pyautogui.keyDown('1')
pyautogui.keyUp('1')
pyautogui.keyUp('ctrlleft')
for iteration in iterations:
pyautogui.keyDown('e')
pyautogui.keyUp('e')
pyautogui.keyDown('e')
pyautogui.keyUp('e')
time.sleep(1)
pyautogui.keyDown('ctrlleft')
pyautogui.keyDown('0')
pyautogui.keyUp('0')
pyautogui.keyUp('ctrlleft')
time.sleep(60)
I believe I've indented the for loop block correctly however attempting to run the script with atbswp gives the following error:
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/lib/python3.9/threading.py", line 973, in _bootstrap_inner
self.run()
File "/usr/lib/python3.9/threading.py", line 910, in run
self._target(*self._args, **self._kwargs)
File "/home/damon/Projects/macros/atbswp/atbswp/control.py", line 388, in play
exec(line)
File "<string>", line 1
for iteration in iterations:
^
IndentationError: expected an indented block
Running the python script directly via python3 works which indicates that the problem is caused by atbswp stripping the indentation, however I would like to be able to make use of atbswp's hotkeys, repeat and infinite replay features when running these scripts so running them directly isn't really a good option.
It seems like a shortcoming that was created when the "stop playback" feature was implemented. Instead of parsing and executing the whole file at once, it's executed line by line. I am not sure what to do about that though. Thanks for reporting.
The solution I can think of here is to run the script directly with python instead of using atbswp. I will now close this issue.