B4J Library jAutoItX Library

Hello,

About AutoIt and AutoIt4Java:
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 Windows applications. It is packaged with AutoItX which supports accessing AutoIt functions through COM objects.
AutoItX4Java uses JACOB to access AutoItX through COM and strives to provide a native Java interface while maintaining the simplicity of AutoIt. Getting started is simple.

How to use this library?:
  1. Copy To external libraries:
    • AutoItX4Java.jar
    • jAutoItX.jar
    • jAutoItX.xml
  2. Copy to your project /Objects/Lib:
    • jacob.dll
    • AutoitX.dll
  3. Register AutoitX.dll with this function (Depends on jShell)
B4X:
Sub AppStart (Form1 As Form, Args() As String)
    'Register autoitX DLL First:
    RegisterAutoItX

    'Initialize jAutoItX:
    AutoItX.Initialize

    '....
End Sub

Private Sub RegisterAutoItX As Boolean
    Dim sh As Shell
    sh.Initialize("", "regsvr32.exe", Array("/s", $""${File.Combine(File.DirApp, "/lib/AutoItX3.dll")}""$))
    Dim Result As ShellSyncResult = sh.RunSynchronous(2000)
    Return Result.Success
End Sub

*For Java 64 bit, please read the notes below.*

143 Methods and 26 Constants:


Licenses (AutoIt, JACOB, Richard Kanavati) -> Please Read:
AutoIt License:
JACOB License:
JACOB is under the license:
GNU Library General Public License, version 2.0
http://www.gnu.org/licenses/old-licenses/lgpl-2.0.en.html
The code of this library is based on the work done by Richard Kanavati. (Big thanks to him )
License:

Notes:
  • This won't work on Linux, Mac OS, B4A, B4I and B4R.
  • You can run the register function every time you start your program, it's safe.
  • The jacob version included in this post is the version 1.18 (x86).
  • For Java 64 bit, download jacob-x.xx-x64.dll (Click HERE), rename it to jacob.dll and replace the old dll.
 

Attachments

  • jAutoItX_Libraries.zip
    256.4 KB · Views: 738
  • jAutoItX_Example.zip
    447.8 KB · Views: 726
Last edited:

jmon

Well-Known Member
Licensed User
Longtime User
error is on this line
I see other errors related to JACOB + autoit :
https://sourceforge.net/p/jacob-project/discussion/375946/thread/aeb31a06/
https://stackoverflow.com/questions...omfailexception-cant-map-name-to-dispid-inire

The first link suggests that the error comes from JNI, probably becuase the same DLL is used in different threads. By any chance do you have the example running twice at the same time?

EDIT:
try un-registering the AutoIt DLL first, then re-register it again?
B4X:
regsvr32 -u <path>\<filename>.dll

EDIT:
Are you running a 64 bit version of JDK?
 

xulihang

Active Member
Licensed User
Longtime User

com.jacob.com.ComFailException: Can't get object clsid from progid

got the same error with jdk x64 on windows10 x64
 

xulihang

Active Member
Licensed User
Longtime User
com.jacob.com.ComFailException: Can't co-create object

sometimes this error
 

jmon

Well-Known Member
Licensed User
Longtime User
got the same error with jdk x64 on windows10 x64
Hi, did you follow the instructions in first post for Java 64 bit?
  • For Java 64 bit, download jacob-x.xx-x64.dll (Click HERE), rename it to jacob.dll and replace the old dll.

Edit : did you register AutoitX?
 

xulihang

Active Member
Licensed User
Longtime User
Hi, did you follow the instructions in first post for Java 64 bit?


Edit : did you register AutoitX?

yes, I did. I also tried x86 JDK, but the same error again.

The compiled jar runs well on another win10 computer. Maybe it is because the environment?
 

xulihang

Active Member
Licensed User
Longtime User
did it with admin privilege. I have given up on it. Maybe I can just go for autoit directly...
 

jmon

Well-Known Member
Licensed User
Longtime User
I have given up on it
You could try a couple things:

- Could you try installing Autoit (https://www.autoitscript.com/site/autoit/downloads/), see if you still run into this problem? The installation will register the COM object properly.

- Otherwise, try registering the dll manually using Regserv32 in the command line.

- The error you are running into are related to the dll no registered properly. Check again the first post to see if you registered the dll properly and copied the files correctly.

- You could check the stdOut and stdErr of this function to see if there was a problem when registering the dll:

B4X:
Private Sub RegisterAutoItX As Boolean
    Dim sh As Shell
    sh.Initialize("", "regsvr32.exe", Array("/s", $""${File.Combine(File.DirApp, "/lib/AutoItX3.dll")}""$))
    Dim Result As ShellSyncResult = sh.RunSynchronous(2000)
    Log(Result.stdOut)
    Log(Result.stdErr)
    Return Result.Success
End Sub
Hope it works!
 

xulihang

Active Member
Licensed User
Longtime User
Hello, jmon. I have tried the autoit3 installation and the dll registration, but it did not work. Anyway, autoit3 just works great. Thank you for your help.
 

xulihang

Active Member
Licensed User
Longtime User
I registered the x64 version of autoit to solve the Can't get object clsid from progid error.
 

Attachments

  • AutoItX3_x64.zip
    158.8 KB · Views: 185

jmon

Well-Known Member
Licensed User
Longtime User
Sorry I've been quiet for a while. I think I found the solution:

1) Download the x64 version of Jacob
2) Download the x64 version of Autoit (Post #30)
3) Register the dll file by giving the full path of regsrv32:
B4X:
Private Sub RegisterAutoItX As Boolean
    Dim sh As Shell
    sh.Initialize("", "C:\Windows\System32\regsvr32.exe", Array("/s", $""${File.Combine(File.DirApp, "/lib/AutoItX3.dll")}""$))
    Dim Result As ShellSyncResult = sh.RunSynchronous(2000)
    Return Result.Success
End Sub

This worked for me. I followed the solution provided here: https://stackoverflow.com/questions/15778383/how-to-register-a-64-bit-com-dll-on-64-bit-windows-7
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…