Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typing uppercase string into a VirtualBox guest results in gibberish #617

Open
mardukbp opened this issue Nov 28, 2024 · 2 comments
Open

Comments

@mardukbp
Copy link

mardukbp commented Nov 28, 2024

Description
Calling the type method of the Controller class with an uppercase string as argument from a Windows host with US keyboard layout results in gibberish when the active window is VirtualBox running a Windows or a Linux guest also with US keyboard layout.

Platform and pynput version
Windows 10 Home 64-bit
pynput 1.7.7

To Reproduce

Requires pywinauto.

import time
from pynput.keyboard import Controller
from pywinauto.findwindows import find_window
from win32gui import SetForegroundWindow

kb = Controller()
SetForegroundWindow(find_window(title_re='.*VirtualBox'))
time.sleep(1)
kb.type("ARROZ CON LECHE")

First run:

image

Second run:

image

The same text, but lowercase is typed correctly.

kb.type("arroz con leche")

image

Pressing Shift before typing and releasing it afterwards works as expected:
(#136 (comment))

kb.press(Key.shift)
kb.type("arroz con leche")
kb.release(Key.shift)

image

@mardukbp
Copy link
Author

I did some more experiments. It turns out that a single uppercase letter is not typed:

kb.type("arRoz")

image

But two consecutive uppercase letters can have an unexpected result:

kb.type("cONfeREnce")

image

@mardukbp
Copy link
Author

mardukbp commented Dec 1, 2024

I performed the same experiment on Fedora with VirtualBox running Windows. Pynput types the uppercase string as lowercase!

import os
import time
from pynput.keyboard import Controller

kb = Controller()
os.system("wmctrl -a VirtualBox")
time.sleep(1)
kb.type("ARROZ CON LECHE")

image

For comparison, pyautogui.write correctly types the uppercase string as uppercase text into the VirtualBox window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant