Using type() with spanish characters: Cannot convert character

Asked by fernando gandini

hi guys,

im trying to use type() to write in some input elements....but i have a lot of 'é, ã, ç, í, etc' on the variables that i have to write....but i getting the "Cannot convert character". I know that type() only work with 'ascii', there is any way to solve that?
I forgot to say that in these fields i can not use the paste ()
thanks

Question information

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

With standard Sikuli there is no chance to do that.

But if you have some knowledge about Java, it is rather easy, to directly use the Java Robot class and its key board methods (these are actually used with Sikuli).

The job to do: find out the key sequences you have to trigger for your special characters.

Revision history for this message
fernando gandini (fernando-gandini) said :
#2

ok, for now i just use .replace to substitute the characters that ascii not recognize.
thanks RaiMan

def tiradorDeCaracteres(texto):

    dic = { "á": "a", "é": "e", "í": "i", "ó": "o", "ú": "u",
      "à": "a", "è": "e", "ì": "i", "ò": "o", "ù": "u",
      "â": "a", "ê": "e", "î": "i", "ô": "o", "û": "u",
      "ã": "a", "õ": "o", "ñ": "n", "ç":"c",
      "Á": "A", "É": "E", "Í": "I", "Ó": "O", "Ú": "U",
      "À": "A", "È": "E", "Ì": "I", "Ò": "O", "Ù": "U",
      "Â": "A", "Ê": "E", "Î": "I", "Ô": "O", "Û": "U",
      "Ã": "A", "Õ": "O", "Ñ": "N", "Ç": "C",
      "Ü": "U", "û":"u", "Ä":"A", "ä":"a", "Ë":"E", "ë":"e",
      "Ï":"I", "ï":"i", "Ö":"O", "ö":"o", "Ü":"U", "ü":"u", "ð":"?", "ß":"ss",
      "Å":"A","å":"a", "ø":"o", "Ø":"O", "Þ":"?" , "æ":"ae",
      "~":"","^":"","`":"", "´":"","&":"","@":"","%":"","ª":"","¢":""
      }

    for i, j in dic.iteritems():
        texto = texto.replace(i, j)
    return texto