paste() on Parallels doesn't work correctly

Asked by emrah kara

Hello,

i am using mac and trying to use sikuli on Windows with Parallels.
the paste() method doesn't work correctly on Windows. it takes always the first paste() method.

like here:

screen.paste("123"); // 123
screen.paste("abc"); // 123
screen.paste("456"); // 123

can anyone help me to solve this problem?

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
RaiMan (raimund-hocke) said :
#1

If I get it right:
Sikuli itself is running in the Windows environment inside of Parallels.

I just tried on my Mac Lion -> Parallels 7 -> Win 7
it works. each paste() does its job.

Their is only one known buggy situation with paste():

it stops to work (always pastes the same), after an Env.getClipBoard() is used in the same script run (might be also in the same IDE Session).

Revision history for this message
emrah kara (emrah-karakoc) said :
#2

Sikuli itself is running on Mac with Java. Sikuli starts the Parallels and then windows.

i tried it in a Simple Methode, but it doesnt work (pastes always the same)

for Example:

public void pasteSomething(){
Screen screen = new Screen();
screen.paste("1"); // pastes 1
screen.paste("2"); // pastes 1
screen.paste("3"); // pastes 1
}

Revision history for this message
emrah kara (emrah-karakoc) said :
#3

Screen screen = new Screen();
screen.paste("1"); // pastes 1

Screen screen2 = new Screen()
screen2.paste("2"); // pastes 1

if i use two different Screen objects, it works. but it is not so good that i have to initial an object, if i want to use paste() methode.

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

On my Mac 10.7 with Parallels 7 copy&paste from Mac to Windows-Parallels does not work at all :-(

might be a typo above:
screen2.paste("2"); // pastes 1

since you said it works this way:
screen2.paste("2"); // pastes 2

and what happens if you simply say:
Screen().paste("2");

this would "only" create a new anonymous Screen object.

Revision history for this message
emrah kara (emrah-karakoc) said :
#5

i don't know why but not even initialing two objects doesn't work :(
it doesn't work :
screen.paste("1"); // pastes 1

screen2.paste("2"); // pastes 1

just using Screen.paste("2") doesnt work neither :(

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

Sorry, did not see: Java ;-)

(new Screen()).paste("2");

based on what you told in comment #3, supposing a typo as mentioned in comment #4.

Revision history for this message
emrah kara (emrah-karakoc) said :
#7

yes but commment #3 doesnt work anymore.. i dont know why :S
es hat mal geklappt aber jetzt macht es das gleiche, fügt immer das gleiche ein obwohl ich zwei ganz verschiedene objekte benutze
:(

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

Since for me copy&paste from Mac to Parallels->Windows does not work at all, I cannot check here.

Does this kind of copy&paste manually work for you?

If yes, so just make a test (you might just use the IDE for that)
- in Mac open a Textedit window and focus
- use the paste() to paste it here
- type("a", Key.CMD); type("x", KEY.CMD); //puts it in the Mac clipboard
- position/click the target in Windows
- type("v", Key.CTRL)

Revision history for this message
emrah kara (emrah-karakoc) said :
#9

but i don't want to copy/ paste.

my code reads url and username from a folder and paste it to the explorer.

screenUrl.paste( server.getUrl());
screenUser.paste( reader.getName());

how could i make a combination of copy a readed String with manually paste?

Revision history for this message
emrah kara (emrah-karakoc) said :
#10

screenUrl.paste( server.getUrl()); this line pastes the url correctly.
screenUser.paste( reader.getName()); this line doesnt paste the username correctly, it pastes still the "url" from the first line!

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

Ok, yes yes, fully understood.

I only suggested to test, wether the normal copy/paste automated with Sikuli works.
Just to sort out the area of problem.

So just set up the suggested script (comment #8) in the IDE and try it (makes only sense, if the manual copy and paste works!)

Revision history for this message
emrah kara (emrah-karakoc) said :
#12

that is my code now to test wether the normal copy/paste works:

1- screen.type("a", InputEvent.META_MASK); //(mac) it works
2- screen.type("x", InputEvent.META_MASK); // (mac) it works

Thread.sleep(6000);

3- screen.type("v", InputEvent.CTRL_MASK); // (parallels-windows) it works

4- screen.paste("google.de"); // (parallels-windows) it doesnt work. it pastes the same from command 3

Revision history for this message
emrah kara (emrah-karakoc) said :
#13

actually i am trying to let Sikuli write the internet adress of a website. that is why it is not a good idea to use type instead of paste.

for example, the url is : http://bla-bla.de
screen.type( server.getUrl()); // types "httpÖ--blaßbla.de"

how could i use type, without having this "paste" problem with parallels, so that it writes the correct letters with my german keyboard, in a dynamic way?

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

ok, so it is really a paste problem.

--- using type() instead of paste() with german keyboard

-- 1: make your own german Key.class
this is possible, but needs some scripting for a tool, that reveals the key codes.

--2: when editing/running the script ...
switch Mac and Windows temporarily to US keyboard

--- making your own copy&paste
Since you are using Java, write your own clipboard manager with a function to set the clipboard content on the Mac and then use type -> ctrl-v on Windows.

Revision history for this message
emrah kara (emrah-karakoc) said :
#15

i will choose the second one ;) Thanks

Revision history for this message
emrah kara (emrah-karakoc) said :
#16

Thanks RaiMan, that solved my question.