asweigart / pyautogui

A cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard.
BSD 3-Clause "New" or "Revised" License
10.47k stars 1.27k forks source link

[Bug] pyautogui.write('%...') writes '5...' #871

Open tddschn opened 3 months ago

tddschn commented 3 months ago

I observed that on my machine (Apple Silicon Mac) with pyautogui 0.9.54, the pyautogui.write(s) method writes the first char as 5 if s starts with %:

Python 3.12.4 (main, Jun  6 2024, 18:26:44) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyautogui
>>> pyautogui.__version__
'0.9.54'
>>> pyautogui.write('%%%')
5%%>>> 5%%
KeyboardInterrupt

In the example, %%% was written as 5%%, which is very weird. I tested writing other strings, and if the first char is %, it always writes 5. However, if I only write a single %, it writes % as expected.

>>> pyautogui.write('%')
%>>> 
KeyboardInterrupt

On US keyboard one would type % with shift + 5 keys. Could you help me figure out why this would happen?