LanX has asked for the wisdom of the Perl Monks concerning the following question:

Hi

OS=Linux

I'm struggling to send special characters like umlauts ("äöüÄÖÜ") via X11::GUITest and SendKeys() to another application.

Is there a trick I am missing? Anything after the first special character is discarded.

If I try the linux tool xte from the package 'xautomation', it works fine from the console:

gnome-text-editor & sleep 1; xte "str äöüÄÖÜß"

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re: X11::GUITest and Umlauts
by choroba (Cardinal) on Oct 17, 2025 at 07:19 UTC
    Confirmed. Not even encoding the keys helps.

    BUT, if I change the input method (via Keyboard Layout Handler) for the window started by the script, it starts typing the accented characters instead of normal ones. Not sure whether I can set the input method from within the script, though.

    Update: I use LeftShift + RightShift to change the input method. The following worked for me:

    PressKey($_), WaitSeconds(0.1) for qw( LSH RSH ); ReleaseKey($_) for qw( LSH RSH ); SendKeys("echo 123\n"); # Sends +ěš instead.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
      So your theory is that I have to change the Keyboard Language Settings for the receiving window?

      And why does "echo 123\n" result in +ěš ?

      (And did you mean ě instead of š ?)

      Actually X11::GUITest is so unreliable that I will probably resort to shelling out to xte.

      It's also sobering that I can't seem to use all of this with Wayland.

      DISCLAIMER: I have DeskFlow installed, an opensource variant of Synergy to share my keyboard over various machines. Anyway deactivating doesn't make a difference. Though can't rule out that there are side effects.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      see Wikisyntax for the Monastery

        > So your theory is

        Theory? It works for me, it's more than just a theory!

        > why does "echo 123\n" result in +ěš ?

        On the Czech QWERTY keyboard, pressing 123 produces +ěš.

        map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

        It's been years since i used it, but you could potentially use Net::VNC as a workaround for sending key codes.

        There's also the venerable X11::Xlib for a bit of low level access. Function XSendEvent() is potentially what you are looking for to send a XKeyEvent. You might also have to look at load_keymap() to look up how to translate Text strings into key codes, because X11 at this level handles row button presses, not text input.

        PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP
        Also check out my sisters artwork and my weekly webcomics
        It's also sobering that I can't seem to use all of this with Wayland.

        Despite all the fanfare, Wayland is really not yet ready for production. I've no doubt that it will get there but that won't be for another few years at the current rate of fixes.

        Stick with X in the meantime - it's had four decades to get things right and at this point is basically rock solid.


        🦛