AutoItX4Java - Java AutoIt Bridge
AutoIt is a very useful automation scripting language for Microsoft Windows. It allows for GUI automation using a very simple syntax and can be useful for testing applications. It is packaged with AutoItX which supports accessing AutoIt functions through COM objects.
I just created a new project on Google Code for Java AutoItX bindings. The project is called AutoItX4Java and uses the JACOB Java COM Bridge to access AutoItX functions. Currently the project is in an unstable state but hopefully as time goes on things will get better tested.
Using AutoItX4Java is simple:
A simple example of using this library is below:
If you need to test whether AutoItX is setup, just enter powershell and do the following:
If your program never stops you can control how Jacob threading works as described here:
I just created a new project on Google Code for Java AutoItX bindings. The project is called AutoItX4Java and uses the JACOB Java COM Bridge to access AutoItX functions. Currently the project is in an unstable state but hopefully as time goes on things will get better tested.
Using AutoItX4Java is simple:
- Download JACOB.
- Download and install AutoIt. (or register the dll. See below)
- Add jacob.jar and autoitx4java.jar to your library path.
- Place the jacob-1.15-M4-x64.dll file in your library path.
A simple example of using this library is below:
File file = new File("lib", "jacob-1.15-M4-x64.dll"); //path to the jacob dll
System.setProperty(LibraryLoader.JACOB_DLL_PATH, file.getAbsolutePath());
AutoItX x = new AutoItX();
String notepad = "Untitled - Notepad";
String testString = "this is a text.";
x.run("notepad.exe");
x.winActivate(notepad);
x.winWaitActive(notepad);
x.send(testString);
Assert.assertTrue(x.winExists(notepad, testString));
x.winClose(notepad, testString);
x.winWaitActive("Notepad");
x.send("{ALT}n");
Assert.assertFalse(x.winExists(notepad, testString));
Troubleshooting: Be sure to use the correct version of the Jacob and AutoItX3 dlls. Both come in x86 and x64 versions.If you need to test whether AutoItX is setup, just enter powershell and do the following:
$x = New-Object -comObject "AutoItX3.Control"
$x.run("Notepad.exe")
If that does not work ensure the AutoItX3.dll is loaded.regsvr32.exe AutoItX3.dll
or
regsvr32.exe AutoItX3_x64.dll
You will also have to be in the x64 version of powershell for this test to work.If your program never stops you can control how Jacob threading works as described here:
ComThread.InitMTA();
AutoItX x = new AutoItX();
x.run("calc.exe");
ComThread.Release();
Hi, Very nice explanation. However where i can download required autoitjar file?
ReplyDeletei am getting below error.
Deletejava.lang.UnsatisfiedLinkError: Can't load library: C:\WINDOWS\system32jacob-1.15-M4-x64.dll
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1706)
Please advice
Could you give the sources of jar?
ReplyDeleteyou can check http://code.google.com/p/autoitx4java/source/checkout
Deletehow do I automate Excel (Open/Edit/Close) using autoitx4java in eclipse
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDelete