0
votes

I am new to robot framework using sikuli library. i would like to maximise the application window using windows key + uparrow. Can you please tell me the keyword that can be used for pressing windows key+uparrow together. looking at sikuli library documentation http://rainmanwy.github.io/robotframework-SikuliLibrary/doc/SikuliLibrary.html#Press%20Special%20Key i understand that there is press special key keyword to press a single key on keyboard. but the question is how to do with two keys.thanks.

3

3 Answers

0
votes

I don't think with current robotframework-sikulilibrary distribution you can pass on more than one arguments to 'Press Special Key' keyword. What you can do is modify that keyword to press a single key or press a keymodifier and another key for example: WIN+UP in your case.

Here's the modification in the library(robotframework-SikuliLibrary/src/java/com/github/rainmanwy/robotframework/sikulilib/keywords/ScreenKeywords.java) that you need:

    @RobotKeyword( "Presses a special keyboard key." 
            + "\n\n For a list of possible Keys view docs for org.sikuli.script.Key ."
            + "\n\n Example Usage:"
            + "\n | Double Click | textFieldWithDefaultText.png | "
            + "\n | Press Special Key | DELETE | ")
@ArgumentNames({"*keyConstant"})
public void pressSpecialKey(String... specialCharName) throws ScreenOperationException{
    try{
        if (specialCharName.length == 1){
            Object key =  Key.class.getField(specialCharName[0]).get(null);
            screen.type(key.toString());
        } else if ( specialCharName.length == 2){
            Object keyModifier =  Key.class.getField(specialCharName[0]).get(null);
            Object key =  Key.class.getField(specialCharName[1]).get(null);
            screen.type(key.toString(),keyModifier.toString());
        }
    }
    catch(ReflectiveOperationException e){
        throw new ScreenOperationException("No " +specialCharName.toString() + " in class org.sikuli.script.Key ");
    }
}

You can do a lot more here yet. But this will serve your purpose, as I used this with WIN+UP and SHIFT+DELETE to test the code.

How you can build your own SikuliLibrary jar with maven, check here. (I don't think I can distribute my version of the Library with the modifications of 'Press Special Key' keyword)

0
votes

You can try this approach:

Screen screen = new Screen();
screen.type(Key.WIN, Key.UP);
0
votes

It's by this:

type(Key.UP, KeyModifier.WIN)