complex commands not working in windows

Asked by shawna_w

i'm trying to highlight a word in notepad.

I've trying shift + end via
  type(Key.END, KEY_SHIFT)

and even tried ctrl + shift + right via
type (Key.RIGHT, KEY_CTRL + KEY_SHIFT)

Windows XP neither work it just goes to the end of the word.

Question information

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

I tried to do some tests with my Win 7:

Key.END e.g. gives a name error: Key

Together with KEY_WIN and KEY_META not running do we have a more general problem with class Key on Windows?

On my Mac 10.6 everything is ok.

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

Sorry, clicked the wrong button (they are weird at all, only wanted to comment)

A question by the way:

How do you manage to get into your Notepad?

I tried with switchApp("Notepad") (you have to do this, so that Notepad gets the focus for keyboard input). This works, but every time opens a new text window!

How then could you be shure, that your type() goes to the Notepad window containing the text you want to work with?

I guess, you click into the Notepad window after the script ends to check the result - true? If yes, this click moves the cursor to the end of text.

Try instead: run your script from the IDE and then use ALT-TAB to bring Notepad to the foreground or just move the IDE away to have a look at the Notepad window without clicking on it.

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

Try to type("anything") into the Notepad window, to check if it works at all.

Revision history for this message
sotn3m (sotn3m) said :
#4

Things like:
type(Key.HOME, KEY_SHIFT)
seems not to work still under Win XP.
Trying:
keyDown(Key.SHIFT)
...
keyUp()
does not solve anything either.
Any ideas?

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

@ sotn3m

I tried with my Win7 32: all the navigation keys work perfectly, either alone or together with modifier keys:

e.g. in a notepad window with the cursor before the first character (ctrl-home):

type(Key.END, KEY_SHIFT + KEY_CTRL)

selects the whole text.

May be you have the problem, that your app that should accept your typing does not have the focus.
Try a switchApp("myApp") before typing. myApp has to be some text from the window title you are targeting at.

Revision history for this message
sotn3m (sotn3m) said :
#6

The application is switched correctly. I would expect "zxcv" out of this:

switchApp("Notepad")
type("asdf")
type(Key.HOME)
type(Key.END,KEY_SHIFT)
type(Key.DELETE)
type("fghj")
type(Key.HOME)
type(Key.END,KEY_SHIFT)
type(Key.DELETE)
type("kl")
type(Key.HOME)
type(Key.END,KEY_SHIFT)
type(Key.DELETE)
type("zxcv")

But I am getting:
asdffghjklzxcv

I have tried Win7. This does not work for me.

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

I sometimes found, that it is necessary to wait a little bit after typing especially keys, that do an action (like deleting or selecting something), to give the app a chance to react (e.g. wait(0.5) was mostly sufficient).

I tried your script on my Win7 (running on an older MacBook Pro from BootCamp) it did what you should expect (but you cannot see what's going on, because it happens too fast)

switchApp("Notepad")
wait(1)
type("asdf")
type(Key.HOME)
type(Key.END,KEY_SHIFT)
wait(1)
type(Key.DELETE)
type("fghj")
wait(1)
type(Key.HOME)
type(Key.END,KEY_SHIFT)
wait(1)
type(Key.DELETE)
type("kl")
wait(1)
type(Key.HOME)
type(Key.END,KEY_SHIFT)
wait(1)
type(Key.DELETE)
type("zxcv")

I took 1 second waiting time, to see, whats going on.

Revision history for this message
sotn3m (sotn3m) said :
#8

I tried that too... Does not work for me.

I have used Spy++ under WinXP. I believe that SHIFT key is released before END is pressed.
I am surprised it is working for you...

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

Then you should try

keyDown(Key.SHIFT)
keyDown(Key.END); keyUp(Key.END) or type(Key.END)
keyUp()

instead of
type(Key.END,KEY_SHIFT)

Revision history for this message
sotn3m (sotn3m) said :
#10

I have tried that too; same effect. (HOME and END works; SHIFT does not)

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

Is KEY_SHIFT generally not working?

Tried type("a", KEY_SHIFT) which should type an A?

Using any special language/keyboard layout?

Revision history for this message
sotn3m (sotn3m) said :
#12

switchApp("Notepad")
type("a", KEY_SHIFT)
wait(1)
type(Key.HOME, KEY_SHIFT)
wait(1)

This would write A, go to the beginning of the line, but it will not select A.
I am using polish keyboard.
Changing WindowsXP keyboard setting to "English (United States)" does not work either.

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

Sorry, no idea, what's going on, since this means, that the constant KEY_SHIFT works, when used with a character.

I apologize in advance for asking this:
This works, when doing it with your fingers on your keyboard?

Revision history for this message
sotn3m (sotn3m) said :
#14

Yes, it works:)

I found partial solution. Turning off "Num lock" solves the problem...
I believe, this is still a bug, because "Num lock" should not influence KEY_SHIFT behavior!

Could you confirm that num lock causes the problem?

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

Since I don't have a real windows machine available (my Win7 is running in BootCamp on a Mac Laptop), I cannot confirm your solution: NumLock is not available for me. But I think you found it.

We should turn this into a bug with the hint how to have a solution. Do you want to do it or should I do it?

Revision history for this message
sotn3m (sotn3m) said :
#16

I have created the bug report.

Revision history for this message
Xpyder (rudd103) said :
#17

I can confirm that I have the same issue

Turning off Num Lock worked for me

Note from the bug ticket: "It's JAVA's bug. We can't fix it."

Can you help with this problem?

Provide an answer of your own, or ask shawna_w for more information if necessary.

To post a message you must log in.