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:

magoandroid

Member
Licensed User
Longtime User
Hi jmon,
thanks for sharing your library.

I think I will be useful.

Greetings.
MAgo
 

jmon

Well-Known Member
Licensed User
Longtime User
I think I will be useful.
I think it is. Just a pity that the win... functions don't work. AutoIt is great for automation and it also allows B4J to know more about things going on outside the javafx window, like the processes and windows etc... I am still trying to make the win function to work properly.
 
Last edited:

Theera

Well-Known Member
Licensed User
Longtime User
Thank you,jmon I've done. But I don't know BuildJavaLibrary.au3 file which attached how is used for create your library.
 
Last edited:

jmon

Well-Known Member
Licensed User
Longtime User
Thank you,jmon I've done. But I don't know BuildJavaLibrary.au3 file which attached how is used for create your library.
Do the "winxxxxx" and "controlxxxx" work for you?

About the BuildJavaLibrary.au3, it's an AutoIt file. You need to install autoit and Scite for Autoit, then in scite, press F5 to execute it. But this conversion of webpage to java script could easily have been done with B4J.

[edit] clarified second paragraph.
 
Last edited:

jmon

Well-Known Member
Licensed User
Longtime User
So.. I have been trying to make the functions "winxxx" and "controlxxxx" work, but no luck so far.

I hope that someone with more knowledge in java will be able to figure where the problems come from.
 

agraham

Expert
Licensed User
Longtime User
So.. I have been trying to make the functions "winxxx" and "controlxxxx" work, but no luck so far.
In what way do they not work? If you are expecting them to work with B4J Forms and Controls then I don't think they will as they are not native Windows controls with Windows handles but are entirely implemented at a very low level by the JavaFX framework. I don't think that .NET WPF applications can be used with AutoIt for the same reason. WPF is an independent GUI framework drawn using DirectX.
 

jmon

Well-Known Member
Licensed User
Longtime User
In what way do they not work?
I use it to get windows outside B4J, on the explorer. For example, if I try to get if a window called "Notepad - Untitled" exists, I would like to use the function:
B4X:
x.winExists("Notepad - Untitled", "")
But just by calling this function, B4J freezes and I have to kill B4J. It's the same with all the win and the control functions.
 

Suntzu

Member
Licensed User
Longtime User
jmon,

Thanks a bunch for the library! It worked like a charm. With a few tweaks, I was able to run the following on both x86 and x64 systems:

xAutoIt.winActivate("XXXXX","")
xAutoIt.winSetOnTop("XXXXX","",True)
 
Last edited:

jmon

Well-Known Member
Licensed User
Longtime User
jmon,

Thanks a bunch for the library! It worked like a charm. With a few tweaks, I was able to run the following on both x86 and x64 systems:

xAutoIt.winActivate("XXXXX","")
xAutoIt.winSetOnTop("XXXXX","",True)
Great! How did you do? On my computer those functions crash. Can you tell me a bit more about your setup? I think I tried on java 7, but not 8.
 

Suntzu

Member
Licensed User
Longtime User
On x86:

1. I downloaded the Jacob package. At the time of writing, version 1.18.
2. I created a folder name "lib" on the same folder where my JAR executable is.
3. Copied jacob-1.18-x86.dll in to the lib folder.
4. Renamed jacob-1.18-x86.dll to jacob-1.17-x86.dll.
5. Tested and it worked.

On x64:

1. I downloaded the Jacob package. At the time of writing, version 1.18.
2. I created a folder name "lib" on the same folder where my JAR executable is.
3. Copied jacob-1.18-x64.dll in to the lib folder.
4. Renamed jacob-1.18-x64.dll to jacob-1.17-x86.dll.
5. Tested and it worked.

My app was compiled on 32-bit Java 7.

Let me know if the above steps work for you.
 
Last edited:

jmon

Well-Known Member
Licensed User
Longtime User
Big Big thanks! You finally closed a bug that was open for more than a year ;-) !

I tested with Java 8u_51on 32bit on Windows 7 x64 and it works!
There is only one function that doesn't work for me, it's the winExists, but all the others work properly now

Thank you again !
Jmon
 
Last edited:

jmon

Well-Known Member
Licensed User
Longtime User
Hi,

I've recompiled the class, and I've simplified the installation instructions. There are just 3 simple steps to follow to install the library.
Now every methods work properly, so no more bug.

Please follow the steps on the post #1 and download the new libraries.

Enjoy
Jmon.
 
Last edited:

JakeBullet70

Well-Known Member
Licensed User
Longtime User
Just got the sample working. My biggest issue was 64bit java, once I went to 32bit all was well!!! Now time for some fun!
 

jmon

Well-Known Member
Licensed User
Longtime User
Last edited:

Douglas Farias

Expert
Licensed User
Longtime User
Hi @jmon
i m folowed the instructions.
but in your example when i compile i got this error.


on this line
B4X:
x.Initialize

what I may have done wrong?

thx
 

jmon

Well-Known Member
Licensed User
Longtime User
what I may have done wrong?
Hi
I'm not sure why.

Did you register AutoIt.Dll before initializing ?
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)
    Return Result.Success
End Sub

Do you see 2 files in the Objects/Lib folder? (Autoitx3.dll, Jacob.dll)

Does the example provided works?

By any chance, are you running Windows 10? Because I have't tested with Win10 yet. Maybe needs to download a new version of autoit dll
 

Douglas Farias

Expert
Licensed User
Longtime User
yes, the libs are on the objects/lib, its your sample, any changes.

and yes its windows 10, maybe this is the problem
 

jmon

Well-Known Member
Licensed User
Longtime User

Douglas Farias

Expert
Licensed User
Longtime User
some progress.
now when i compile show error on another place.


error is on this line
B4X:
LogMe(x.iniWrite(FileName, "Section1", "Key1", "This is the value"))
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…