add counter function
This commit is contained in:
+14
-3
@@ -21,7 +21,7 @@ from .command import Command
|
||||
|
||||
class Window:
|
||||
__AUTHOR__ = 'anima'
|
||||
__VERSION__ = '1.1.6'
|
||||
__VERSION__ = '1.2.0'
|
||||
|
||||
key_press_duration = 0.1
|
||||
supported_keys = ['return', 'Up', 'Down', 'Right', 'Left']
|
||||
@@ -45,14 +45,18 @@ class Window:
|
||||
self.dry_run = False
|
||||
|
||||
|
||||
def run(self):
|
||||
def run(self) -> bool:
|
||||
"""main loop to screenshot given monitor and match with screens
|
||||
|
||||
Returns:
|
||||
bool: True if a clean fin
|
||||
"""
|
||||
if not len(self.commands) > 0:
|
||||
logging.error(f'no commands to run found')
|
||||
sys.exit(1)
|
||||
with mss.mss() as self.sct:
|
||||
while True:
|
||||
command = self.match_screen()
|
||||
# print(self.match_screen())
|
||||
if command:
|
||||
self.activate_window()
|
||||
for key in command.commands:
|
||||
@@ -60,7 +64,14 @@ class Window:
|
||||
self.send_key(key)
|
||||
elif isinstance(key, int) or isinstance(key, float):
|
||||
time.sleep(key)
|
||||
command.count += 1
|
||||
if isinstance(command.counter, int):
|
||||
logging.info(f'{command.name} counter: {command.count} / {command.counter}')
|
||||
if command.count >= command.counter:
|
||||
logging.info(f'{command.name} hast reach counter limit. stop script')
|
||||
return True
|
||||
time.sleep(self.poll_intervall)
|
||||
return False
|
||||
|
||||
## Screen Managament
|
||||
def grab_screen(self) -> numpy.ndarray:
|
||||
|
||||
Reference in New Issue
Block a user