0

My query is how do I call the various UDF (user defined functions) of autoIT in Java using COM (component object model) just like the sample code mentioned below:

somewhat like this:

 File file = new File("lib" , "jacob-1.18-x64.dll");
 System.setProperty(LibraryLoader.JACOB_DLL_PATH, file.getAbsolutePath());

 AutoItX x = new AutoItX();
 x.run("calc.exe");
 x.winActivate("Calculator");
 x.winWaitActive("Calculator");
 //Enter 3
 x.controlClick("Calculator", "", "133") ;
 Thread.sleep(1000);
 //Enter +
 x.controlClick("Calculator", "", "93") ;
 Thread.sleep(1000);
 //Enter 3
 x.controlClick("Calculator", "", "133") ;
 Thread.sleep(1000);
 //Enter =
 x.controlClick("Calculator", "", "121") ;
5
  • What u need to do? can u avoid it? Commented Dec 21, 2016 at 12:13
  • I need to open an Excel , Update and verify few cells , Then save it. I can't avoid it. Commented Dec 21, 2016 at 12:19
  • no need for autoit there. use apache poi or something similar to do such things with java Commented Dec 21, 2016 at 12:19
  • basically I am trying to automate browser related actions using selenium and non-browser related actions through AutoIT (in this case excel) but there are scenarios where I will not necessarily only be working with excel but any number of windows application. My query is how do I call the various UDF (user defined functions) of autoIT in Java using COM (component object model) just like the sample code mentioned in the question. Commented Dec 21, 2016 at 12:33
  • When i was reading your question , it seems that you are using autoit for a browser. please read toolsqa.com/selenium-webdriver/custom-firefox-profile Commented Dec 21, 2016 at 12:58

1 Answer 1

1

You cannot use existing AutoIt code using AutoItX. You have two options if you want to use AutoIt:

  1. Compile an AutoIt script that does what you want and call it from your Java program.

  2. Convert the UDF to Java/AutoItX

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks. Options 1 - this is one possible solution but it does not give enough flexibility. Option 2 - This is the one that I am looking for. Can you help how to I convert the UDF to Java/AutoITx.
It's not an easy option. Open up the UDF and start reimplementing the bits you need. AutoIT executables can be used to execute any autoit script, so you could always generate the script you need using Java and then execute it.
Thanks. could you please briefly mention the steps (not the actual code) of converting the UDF to java/AutoITx. As I am new to DLL and COM Interface.
It will depend on what you want to do, but I expect there will be quite a bit of work with the Windows API. It might be easier to do things directly in Java. e.g., for excel, see javaworld.com/article/2074940/learn-java/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.