From d998bf317b9010e5daf2261c9abc434485e4aa4f Mon Sep 17 00:00:00 2001 From: Scott Poore Date: Wed, 27 Nov 2024 16:36:55 -0600 Subject: [PATCH] GUI: update kb_write to handle upper case chars kb_write sent the text directly two keyboard.write() which doesn't handle uppercase characters. A workaround is to use keyboard.sent() to send shift+ for the uppercase characters and rely on keyboard.write() to send the rest. --- SCAutolib/models/gui.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/SCAutolib/models/gui.py b/SCAutolib/models/gui.py index 295acc9..e8a2392 100644 --- a/SCAutolib/models/gui.py +++ b/SCAutolib/models/gui.py @@ -379,7 +379,18 @@ def click_on(self, key: str, timeout: float = 30): def kb_write(self, *args, **kwargs): # delay is a workaround needed for keyboard library kwargs.setdefault('delay', 0.1) - keyboard.write(*args, **kwargs) + + word = args[0] + last = "" + for char in word: + if char.isupper(): + if last != "": + keyboard.write(*[last], **kwargs) + last = "" + keyboard.send(f"shift+{char.lower()}") + else: + last = f"{last}{char}" + keyboard.write(*[last], **kwargs) @action_decorator @log_decorator