[英]automatically press enter key after milliseconds java
我已經編寫了一個php代碼並建立了一個jar文件。 通過php,我將參數發送到jar文件。 在jar文件中,我基本上使用掃描儀-nextLine讀取參數。
我的問題是,如何才能實現像Enter鍵那樣的代碼以繼續執行該程序? 當我發送參數時,讓我說10毫秒后,java將自動按鍵。
感謝您的任何進步。
我將使用停止字符,而不是模擬的按鈕單擊。 附加通常在php生成的字符串中找不到的特殊字符,然后讓掃描儀逐個字符讀取它,直到找到特殊字符為止。
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
希望這可以幫助
據我了解,請使用getKeyCode()檢查KeyEvent或在10毫秒后直接將keyCode傳遞為hardCoded。
$('textarea').bind("enterKey",function(e){
//do stuff here
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.