1

I need to press WINDOW + UpArrow.

At first attempt I have tried with sikuli by :-

s1.type(Key.WIN + Key.UP);

But it only press WINDOW and UpArrow buttons, but separately.

By selenium I have try with Actions class but I have found there is no key available to press WINDOW button there.

Ripon Al Wasim
  • 36,924
  • 42
  • 155
  • 176
Shubham Jain
  • 16,610
  • 15
  • 78
  • 125
  • I have done my operation using Robot Class for same. Robot robot = new Robot(); robot.keyPress(KeyEvent.VK_WINDOWS); robot.keyPress(KeyEvent.VK_UP); robot.keyRelease(KeyEvent.VK_WINDOWS); robot.keyRelease(KeyEvent.VK_UP); – Shubham Jain Oct 09 '14 at 15:05
  • For using Robot class, what jar should be added? And what package is needed? – Ripon Al Wasim Jun 01 '15 at 11:06
  • You do not need to import any additional java library. You just need to to have jdk version equal or greater than 1.7 import java.awt.Robot; import java.awt.event.KeyEvent; – Shubham Jain Jun 02 '15 at 12:37

1 Answers1

5

In sikuli, if you want to simulate pressing and holding one button, while then typing another, use type(TheKeyDoingTheAction, KeyModifier.TheKeyYoureHoldingDown It's written like this:

type(Key.UP, KeyModifier.WIN) #This is the one from your question

Here are a few other common examples:

type("c", KeyModifier.CTRL) #copies whatever is selected to the clipboard
type(Key.LEFT, KeyModifier.ALT) #goes back one page in most web browsers

Here's an exerpt from the sikuli docs:

"The modifier constants can be combined to the modifier parameter by either using “+” or “|”, if more than one key modifier is needed.

type(Key.ESC, KeyModifier.CTRL + KeyModifier.ALT)
# or equivalent -
type(Key.ESC, KeyModifier.CTRL | KeyModifier.ALT)

They should only be used in the modifiers parameter with functions like type(), rightClick(), etc. They should never be used with keyDown() or keyUp()."

autoKarma
  • 819
  • 5
  • 10