[英]automatically press enter key after milliseconds java
I have written a php code and built a jar file. 我已经编写了一个php代码并建立了一个jar文件。 Through php I send parameters to jar file.
通过php,我将参数发送到jar文件。 In jar file I basically read the parameter with scanner - nextLine.
在jar文件中,我基本上使用扫描仪-nextLine读取参数。
My question is, how can I implement such a code that acts like an Enter key to be able to continue the program? 我的问题是,如何才能实现像Enter键那样的代码以继续执行该程序? When I send the parameter, let me say after 10 milliseconds, java will press key automatically.
当我发送参数时,让我说10毫秒后,java将自动按键。
Thanks for any advance. 感谢您的任何进步。
I would use a stop character, instead of a simulated button click. 我将使用停止字符,而不是模拟的按钮单击。 Append a special character that is normally not found in your php-generated string and let your scanner read it character by character until special char is found.
附加通常在php生成的字符串中找不到的特殊字符,然后让扫描仪逐个字符读取它,直到找到特殊字符为止。
Java code: Java代码:
boolean found = false;
String parameter = "";
Scanner sc = new Scanner(System.in);
while(!found){
String input = sc.next();
parameter += input + "\n";
if(input.contains('<specialchar>')
found = true;
}
Thread.CurrentThread().wait(10);
//here goes the code to deal with finished input
Hope this helps 希望这可以帮助
据我了解,请使用getKeyCode()检查KeyEvent或在10毫秒后直接将keyCode传递为hardCoded。
$('textarea').bind("enterKey",function(e){
//do stuff here
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.