Skip to content

Commit

Permalink
GUI: update kb_write to handle upper case chars
Browse files Browse the repository at this point in the history
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+<char> for the uppercase characters and rely on
keyboard.write() to send the rest.
  • Loading branch information
spoore1 committed Nov 27, 2024
1 parent ec4d04b commit d998bf3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion SCAutolib/models/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d998bf3

Please sign in to comment.