Not possible to type() chinese letters - try paste() with unicode strings u"..."

Asked by quan4wen

i want search something in google
but the key of search is chinese
in the sikulIDE ,my code is
click( ) note:the click object is IEPLORE
type( ,"中国") note:i put the key in the google home

now the question is
when i excute is code,the program will done and put some errormessage
the errormessage is
thank for your answer

[error] 错误信息: Traceback (most recent call last): File "F:\Users\qw\AppData\Local\Temp\sikuli-tmp2259224127046214228.py", line 2, in type(Pattern("EEEHE.png").targetOffset(-94,7),"涓浗") File "F:\Program Files\Sikuli X\sikuli-script.jar\Lib\sikuli\Region.py", line 165, in type Line 2, in file F:\Users\qw\AppData\Local\Temp\sikuli-tmp2259224127046214228.py at org.sikuli.script.Region.handleFindFailed(Region.java:349) at org.sikuli.script.Region.wait(Region.java:420) at org.python.proxies.sikuli.Region$Region$1.super__wait(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) org.sikuli.script.FindFailed: FindFailed: can not find Pattern("EEEHE.png").similar(0.7).targetOffset(-94,7) Line 2, in file F:\Users\q
w\AppData\Local\Temp\sikuli-tmp2259224127046214228.py

Question information

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

-- 1.
your major problem is, that the image named "EEEHE.png" (whatever this might be) cannot be found on the screen:
near the end of the error message:
FindFailed: can not find Pattern("EEEHE.png").similar(0.7).targetOffset(-94,7) Line 2,

-- 2.
type cannot be used to type some characters found on the standard US-keyboard layout (read: faq 933).

-- 3.
when finally trying paste() instead, you might try to use unicode strings:
in your case:
chineseString = u"中国"
paste(chineseString)

Revision history for this message
RaiMan (raimund-hocke) said :
#2

sorry for the mistake at --2., should read:

-- 2.
type can only be used to type some characters found on the standard US-keyboard layout (read: faq 933).

Revision history for this message
quan4wen (quanwen20006) said :
#3

my question is solved,

use variable,define variable and set value to the variable

example

chineseString = u"中国"
paste(chineseString)

thanks RailMan