如何使用 Sikuli Java Standalone jar 输入特殊键?

问题描述 投票:0回答:4

Sikuli X 我可以使用类似

的东西
type("x", KEY_CTRL)

如何在 Sikuli API 中执行相同操作?

java sikuli
4个回答
1
投票

我在我的项目中使用了这种方式:

Screen screen = new Screen();

screen.click(<your texbox>); // click into textbox to have a cursor there

screen.type("a", KeyModifier.CTRL); // this sends Ctrl+"a" to select all text <- this is what you asked for !
screen.type(Key.BACKSPACE); // this sends Backspace key pressed, i.e. here deletes all selected text

请注意,我同时使用了 KeyModifier 和 Key。这样就成功了。


1
投票

试试这个,

Screen screen = new Screen();
screen.type("x",Key.CTRL)
screen.type("\n");

0
投票

使用KeyEvent中的按键代码:

DesktopKeyboard keyboard = new DesktopKeyboard();
keyboard.keyDown(KeyEvent.VK_CONTROL);
keyboard.type("x");
keyboard.keyUp(KeyEvent.VK_CONTROL);

0
投票

我写了一个 typeChaine 函数:

def typeChaine(chr):
#    print (msg.format(chr))
    for car in chr: 
#        print(car)
        keyDown(Key.ALT)
        type(Key.NUM0)
        for num in str(ord(car)):
            #type(Key.NUMnum)
            print(num)
            if (num == "0"):
                type(Key.NUM0)
            elif (num == "1"):
                type(Key.NUM1) 
            elif (num == "2"):
                type(Key.NUM2) 
            elif (num == "3"):
                type(Key.NUM3) 
            elif (num == "4"):
                type(Key.NUM4) 
            elif (num == "5"):
                type(Key.NUM5) 
            elif (num == "6"):
                type(Key.NUM6) 
            elif (num == "7"):
                type(Key.NUM7) 
            elif (num == "8"):
                type(Key.NUM8) 
            elif (num == "9"):
                type(Key.NUM9) 
        keyUp(Key.ALT)
© www.soinside.com 2019 - 2024. All rights reserved.