← Back to team overview

sikuli-driver team mailing list archive

[Bug 1317813] Re: Clipboard issues, old data isnt cleared

 

# -*- coding: utf-8 -*-
is not needed in scripts run with Sikuli, since this is added automatically at runtime

Other things I admit, are not documented yet:

popup() finally takes the text as unicode string. Since from clipboard
it is returned as unicode string already from the Java level, this
should work in your case:

# any code, that puts "ÄÖÜäöü" on the clipboard (I am on a german keyboard, tested on Mac ;-)
text = Env.getClipboard()
popup(text)

should show up as expected
print text should complain non-ASCII

print text.encode("utf-8") # works on command line
but prints question marks to the IDE's message area (has to be fixed)

there is a helper:
uprint(text) internally does the encoding to UTF-8
and can be used the same way as print

Another quirk:
popup("ÄÖÜäöü") does not work

but this works:
popup(unicode("ÄÖÜäöü",  "utf-8"))

and again there is a helper:
popup(unicd("ÄÖÜäöü"))

conclusion:
just staying with utf-8 should work.

Strings, that are generated on the script level (like text = "ÄÖÜäöü")
have to be unicode strings when given down to the Java layer (like with
popup()) and hence to be converted using unicode(string, "utf-8")
(helper: unicd() )

-- 
You received this bug notification because you are a member of Sikuli
Drivers, which is subscribed to Sikuli.
https://bugs.launchpad.net/bugs/1317813

Title:
  Clipboard issues, old data isnt cleared

Status in Sikuli:
  In Progress

Bug description:
  Hi.

  I ran across an issue (it occurs in about 1 out of 30 trials) where
  old data gets passed from the clipboard to the paste function.

  Code:
          tripleClick(Pattern("1392988992662.png").targetOffset(70,2))
          type("c", KEY_CTRL)
          adress = Env.getClipboard().encode('iso-8859-15').strip()

  and paste part... about 350 SLOC later:
          paste(u"V\xC4GD 1")

  For some reason it picks a random object from the clipboard (and
  sometimes its not even the last copied item either...)

  And why am I doin it this way? Well, its because special characters
  (like ÅÄÖ) arent very popular and cant be written using the type()
  function. But paste(u"") works.

  Is this a problem in SikuliX or the Clipboard or somewhere else?

  Machine = Win7 Pro SP1

To manage notifications about this bug go to:
https://bugs.launchpad.net/sikuli/+bug/1317813/+subscriptions


References