How to press page down with Shift holded

Asked by John008

This question I post here to save the time to many others since I spent a lot of time to figure out the only combination that works. I have found solution.

Task: To Hold SHIFT while pressing PgDown twice to select some bulk text in application

Answer:

   if Env.isLockOn(Key.NUM_LOCK):
        nlZap=True
    else:
        nlZap=False
    if nlZap: type(Key.NUM_LOCK)
    keyDown(Key.SHIFT)
    type(Key.PAGE_DOWN, Key.SHIFT)
    type(Key.PAGE_DOWN, Key.SHIFT)
    keyUp(Key.SHIFT)
    if nlZap: type(Key.NUM_LOCK)

It has something to do with Numlock state and also at the same time the above combination must be used of KeyDown and key modifier. Many millions of other combinations, constants, etc.... did not work at all.

Best Regards,

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
John008 (filipre2) said :
#2

About the redundancy:
I am 100% sure that until I added the modification key, it did not work.
The main point was to repeat the SHIFT modifier also with having it Keyed Down.

Therefore I think the piece of code is not redundant as I found after several hours of tests. It may be my very specific App in combination with Windows, but I hope I help others avoid such long experimenting, in fact the "reundant part" was the reason I made this post :-]

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

ok, made the comment invisible.

Thanks for the contribution.

I will revise the keyboard handling with version 1.2.

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

this is for others to know.

Revision history for this message
John Henckel (henckel-jonathan) said :
#5

I encountered the SAME bug. I am using the Java API. When NUMLOCK is true, the Shift + End (or pgdn, or arrow) does not work as expected. I think that this is a BUG in the java.awt.Robot.

I tried the following

                Robot r = new Robot();
                r.keyPress(KeyEvent.VK_SHIFT);
                r.keyPress(KeyEvent.VK_END);
                r.keyRelease(KeyEvent.VK_END);
                r.keyRelease(KeyEvent.VK_SHIFT);

and it works differently depending on the NUMLOCK state.

Revision history for this message
John Henckel (henckel-jonathan) said :
#6
Revision history for this message
RaiMan (raimund-hocke) said :
#7

@John Henckel
thanks for the information and the link.
I make it a request bug, to put the workaround into Sikuli's key handling.