如何使用 Sikuli Java Standalone jar 输入文本?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15196238/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 18:47:45  来源:igfitidea点击:

How to type text using Sikuli Java Standalone jar?

javasikuli

提问by Nikhil K R

I am using Java Standalone APIs of Sikuli to automate my application.

我正在使用 Sikuli 的 Java Standalone API 来自动化我的应用程序。

I don't know how to provide/feed some text to any text-fields using this.

我不知道如何使用它向任何文本字段提供/馈送一些文本。

回答by Nathaniel Waisbrot

Assuming that the cursor is currently active in a text field:

假设光标当前在文本字段中处于活动状态:

Keyboard kb = new DesktopKeyboard();
kb.type("Hello world");

Or, assuming that the field accepts paste and that you don't need to simulate the individual key-presses

或者,假设该字段接受粘贴并且您不需要模拟单个按键

kb.paste("Hello world");

If you have a set of fields and tab moves between them, you can do

如果您有一组字段和选项卡在它们之间移动,您可以这样做

kb.paste("Hello");
kb.type(Key.TAB);
kb.paste("World");

回答by Alessandro Da Rugna

Since the question is quite broad to answer, I'm giving you some useful links. You can find the Java development setup basis on the Sikuli Documentation.

由于这个问题的回答范围很广,我给了你一些有用的链接。您可以在Sikuli 文档中找到 Java 开发设置基础。

Here's a more in-depth tutorialthat also covers your exact problem, and all the available Javadocs.

这是一个更深入的教程,其中还涵盖了您的确切问题以及所有可用的Javadoc

Just use the type()method on the desidered locator.

只需type()在所需的定位器上使用该方法。

With Sikuli-api try

用sikuli-api试试

Keyboard keyboard = new DesktopKeyboard();
keyboard.type("abc");

https://answers.launchpad.net/sikuli/+question/218670

https://answers.launchpad.net/sikuli/+question/218670

回答by Mahi

you can also use sikuli method type() in java program.

你也可以在java程序中使用sikuli方法type()。

example:

例子:

 Screen screen=new Screen();

1st create object for screen. then call method type() using that reference.

第一个为屏幕创建对象。然后使用该引用调用方法 type()。

screen.type("your text");