Search code examples
javaautomationautoitjacob

Java and Autoit can't send key like TAB, ENTER or something else?


I'm new to autoit and trying to integrate it with a java app. I can't make it send enter or tab or ctrl, it sends only plain text.

The code is this:

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){

   } 
}                                        

I already tried:

  • x.controlSend("Window Title","text","","{ENTER}",false);
  • x.send("{TAB}!n" );
  • x.send("{TAB}n" );

Solution

  • It works with true or false thy to Milos for giving me the solution

        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){
    
       } 
    }                                        
    

    Thy all for the help