Type Keys with Interval does not work with UTF-8

When I use paste() it send special characters, or even when I print on console. But type_keys_with_interval(interval, keys) skips the special characters, for example, I want to write in portuguese: “Olá, meu nome é José”, the outcome is “Ol, meu nome Jos” which is undesirable.
How to fix it?

1 Like

Hello @Camila , are you using WebBot or DesktopBot? could you put this part of the code here?

DesktopBot

            
            #im using pandas here to get data from a csv file
            text = str(df.loc[x, "COLUMN"])

            self.type_keys_with_interval(100, text)
            #self.paste(text)

The type_keys_with_interval() method is used for keyboard shortcuts, use the paste() method instead of type_keys_with_interval().

# type_keys_with_interval
self.type_keys_with_interval(interval=100, keys=['ctrl', 'shift', 'esc'])

# paste
self.paste(text='olá')

Paste does work with special character like I wish, but I liked the type keys with interval for the effect of looking similar to human’s way to type.

@Camila for a human’s way to type you can use the kb_type method and customize the interval parameter.
Here is the reference: Framework - BotCity Framework Core - Python

Let me know if this works for you.

I appreciate your tip! It’s just it still didn’t accomplish what I was trying to do, which is typing something with accents such as: “Macarrão”

@Camila thank you for reporting this. We are looking into this limitation with accents and will get back to you.

For now, as a workaround to achieve the same human behavior you can create a method on your bot like this:

def write_text(self, text, interval=100):
    clip = self.get_clipboard()
    for t in text:
        self.paste(t, wait=interval)
    self.copy_to_clipboard(clip)

Let me know if this helps as a workaround. We are looking into a permanent solution to this issue and we are tracking it here: kb_type() and type_keys() methods don't work for special characters · Issue #23 · botcity-dev/botcity-framework-core-python · GitHub