Typing with swedish letters

Asked by Mehrdad

Hello Sikuli,

Thank you for a great product! We use version X-1.0rc3 together with Robot Framework version 2.6.3.

We use it for testing a product in Sweden, and we need to be able to type text with Swedish letters in it (e.g. å, ä, ö). Here’s what we’re doing now:

    from sikuli.Sikuli import *

    def etype(self, text):
        for char in text:
            if char == "\xe5": # if it's å
                r = Region(0, 0, 1000, 1000)
                r.keyDown(Key.ALT)
                type(Key.NUM1 + Key.NUM3 + Key.NUM4)
                r.keyUp(Key.ALT)
            elif char == "\xf6": # if it's ö
                r = Region(0, 0, 1000, 1000)
                r.keyDown(Key.ALT)
                type(Key.NUM1 + Key.NUM4 + Key.NUM8)
                r.keyUp(Key.ALT)
            else:
                type(char)

Is there a better way to solve this issue? Preferably by using the letters within strings in the code.

Regards,
-Mehrdad

Mehrdad Shahnavazi
Tester, automation

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

currently on Windows this is the only possibility with type() to use such special non-US characters.

But you might use paste() instead, which allows to use any utf8 character.

Be aware: For special keys like arrow keys and other special keys you have to use type()

e.g.
paste("Björn")
type(Key.TAB) # get to next field
paste("Sårstrup")
type(Key.ENTER)

Can you help with this problem?

Provide an answer of your own, or ask Mehrdad for more information if necessary.

To post a message you must log in.