Java 并且 Autoit 无法发送像 TAB、ENTER 或其他键这样的键?
Java and Autoit can't send key like TAB, ENTER or something else?
我是 autoit 的新手,正在尝试将其与 java 应用程序集成。我无法让它发送 enter 或 tab 或 ctrl,它只发送纯文本。
代码是这样的:
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
String jacobDllVersionToUse;
if (jvmBitVersion().contains("32")){
jacobDllVersionToUse = "jacob-1.18-M2-x86.dll";
}
else {
jacobDllVersionToUse = "jacob-1.18-M2-x64.dll";
}
try{
File file = new File("lib", jacobDllVersionToUse);
System.setProperty(LibraryLoader.JACOB_DLL_PATH, file.getAbsolutePath());
AutoItX x = new AutoItX();
x.run("Skype", "C:/Program Files (x86)/Skype/Phone", AutoItX.SW_SHOW);
x.winActivate("Skype");
x.winWaitActive("Skype");
x.sleep(2000);
x.send("{TAB}!n" );
}catch(Exception e){
}
}
我已经试过了:
x.controlSend("Window Title","text","","{ENTER}",false);
x.send("{TAB}!n" );
x.send("{TAB}n" );
您缺少 WinWait。
试试这个
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
String jacobDllVersionToUse;
if (jvmBitVersion().contains("32")){
jacobDllVersionToUse = "jacob-1.18-M2-x86.dll";
}
else {
jacobDllVersionToUse = "jacob-1.18-M2-x64.dll";
}
try{
File file = new File("lib", jacobDllVersionToUse);
System.setProperty(LibraryLoader.JACOB_DLL_PATH, file.getAbsolutePath());
AutoItX x = new AutoItX();
x.run("Skype", "C:/Program Files (x86)/Skype/Phone", AutoItX.SW_SHOW);
x.winWait("Skype");
x.winActivate("Skype");
x.winWaitActive("Skype");
x.sleep(2000);
x.send("{TAB}!n", false );
}catch(Exception e){
}
}
它与 true 或 false 一起工作 Milos 为我提供了解决方案
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
String sql="select * from app_1 where id_user_main=?";
String jacobDllVersionToUse;
if (jvmBitVersion().contains("32")){
jacobDllVersionToUse = "jacob-1.18-M2-x86.dll";
}
else {
jacobDllVersionToUse = "jacob-1.18-M2-x64.dll";
}
try{
File file = new File("lib", jacobDllVersionToUse);
System.setProperty(LibraryLoader.JACOB_DLL_PATH, file.getAbsolutePath());
AutoItX x = new AutoItX();
x.run("Skype", "C:/Program Files (x86)/Skype/Phone", AutoItX.SW_SHOW);
x.winWait("Skype");
x.winActivate("Skype");
x.winWaitActive("Skype");
x.sleep(2000);
x.send("{TAB}!n", false );
}catch(Exception e){
}
}
请大家帮忙
我是 autoit 的新手,正在尝试将其与 java 应用程序集成。我无法让它发送 enter 或 tab 或 ctrl,它只发送纯文本。
代码是这样的:
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
String jacobDllVersionToUse;
if (jvmBitVersion().contains("32")){
jacobDllVersionToUse = "jacob-1.18-M2-x86.dll";
}
else {
jacobDllVersionToUse = "jacob-1.18-M2-x64.dll";
}
try{
File file = new File("lib", jacobDllVersionToUse);
System.setProperty(LibraryLoader.JACOB_DLL_PATH, file.getAbsolutePath());
AutoItX x = new AutoItX();
x.run("Skype", "C:/Program Files (x86)/Skype/Phone", AutoItX.SW_SHOW);
x.winActivate("Skype");
x.winWaitActive("Skype");
x.sleep(2000);
x.send("{TAB}!n" );
}catch(Exception e){
}
}
我已经试过了:
x.controlSend("Window Title","text","","{ENTER}",false);
x.send("{TAB}!n" );
x.send("{TAB}n" );
您缺少 WinWait。
试试这个
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
String jacobDllVersionToUse;
if (jvmBitVersion().contains("32")){
jacobDllVersionToUse = "jacob-1.18-M2-x86.dll";
}
else {
jacobDllVersionToUse = "jacob-1.18-M2-x64.dll";
}
try{
File file = new File("lib", jacobDllVersionToUse);
System.setProperty(LibraryLoader.JACOB_DLL_PATH, file.getAbsolutePath());
AutoItX x = new AutoItX();
x.run("Skype", "C:/Program Files (x86)/Skype/Phone", AutoItX.SW_SHOW);
x.winWait("Skype");
x.winActivate("Skype");
x.winWaitActive("Skype");
x.sleep(2000);
x.send("{TAB}!n", false );
}catch(Exception e){
}
}
它与 true 或 false 一起工作 Milos 为我提供了解决方案
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
String sql="select * from app_1 where id_user_main=?";
String jacobDllVersionToUse;
if (jvmBitVersion().contains("32")){
jacobDllVersionToUse = "jacob-1.18-M2-x86.dll";
}
else {
jacobDllVersionToUse = "jacob-1.18-M2-x64.dll";
}
try{
File file = new File("lib", jacobDllVersionToUse);
System.setProperty(LibraryLoader.JACOB_DLL_PATH, file.getAbsolutePath());
AutoItX x = new AutoItX();
x.run("Skype", "C:/Program Files (x86)/Skype/Phone", AutoItX.SW_SHOW);
x.winWait("Skype");
x.winActivate("Skype");
x.winWaitActive("Skype");
x.sleep(2000);
x.send("{TAB}!n", false );
}catch(Exception e){
}
}
请大家帮忙