Sign in to follow this  
Followers 0

Call AutoItX Directly (VB 2010)

17 posts in this topic

Posted

Is it possible to call AutoItX dll directly into my application? I plan on having my program on multiple computers, and I don't want to have to register it for every computer.

So is there a way to just use the functions of AutoItX? I don't want to have to make an installer either. I just wany my single .EXE file with all my AI functions.

Thanks!

Share this post


Link to post
Share on other sites



Posted

You will need to include the dll file. You don't have to register it if you call it like a dll instead of a COM object.

Share this post


Link to post
Share on other sites

Posted

Do you know how to do it in VB?

Share this post


Link to post
Share on other sites

Posted

No. I haven't touched VB in a very long time.

Share this post


Link to post
Share on other sites

Posted

AutoItX3.dll math with vb.net. you try.

Share this post


Link to post
Share on other sites

Posted

Just "add reference" to the AutoitX.dll and set Embed Interop Types" to FALSE (see properties tab in references). This worked ok for me.

In the class where you want to use AutoIt functionality (C# code):

AutoItX3Lib.AutoItX3Class au3 = new AutoItX3Lib.AutoItX3Class();

au3.AutoItSetOption("WinTitleMatchMode", 2);

au3.WinWaitActive(windowName, "", maxTimeInSec)

...

Share this post


Link to post
Share on other sites

Posted

Just "add reference" to the AutoitX.dll and set Embed Interop Types" to FALSE (see properties tab in references). This worked ok for me.

In the class where you want to use AutoIt functionality (C# code):

AutoItX3Lib.AutoItX3Class au3 = new AutoItX3Lib.AutoItX3Class();

au3.AutoItSetOption("WinTitleMatchMode", 2);

au3.WinWaitActive(windowName, "", maxTimeInSec)

...

Do I have to register it on the host computer first and then do that? Because, when I try to add a reference without registering, I receive error, "A Reference To AutoItX3_X64.dll could not be added. Please make sure that the file is accessible..."

Please get back to me ASAP. :) Thanks!

Share this post


Link to post
Share on other sites

Posted

I did not need to register on the host computer (XP). I did not test on 64bit however, only on Win7 32 and on XP. Both worked without any problems (Win 7 pc has however AutoIt editor installed)

Share this post


Link to post
Share on other sites

Posted

I you are using the COM method, you will need to register it.

If you are using directly, the dll, you do not have to register it

In either case, it must be linked properly from within your IDE.

Share this post


Link to post
Share on other sites

Posted

Forgot to mention, but as JohnOne said, I am using the DLL directly from the lib folder in my solution.

Share this post


Link to post
Share on other sites

Posted

Forgot to mention, but as JohnOne said, I am using the DLL directly from the lib folder in my solution.

Yes, but I don't see a "lib" folder and the only way to add a DLL to VS is to add it as a reference. In which case, I have to register it. I don't understand...

Share this post


Link to post
Share on other sites

Posted

A simple way is using LoadLibrary and GetProcAddress.

Share this post


Link to post
Share on other sites

Posted

A simple way is using LoadLibrary and GetProcAddress.

Well, that sounds good. I'm familiar with API. Can I follow this guide?

http://www.omegajunior.net/code/vbnet_unmanaged.html

It seems like it should work, but I would like to make sure before I spend countless hours on something that won't work.

Share this post


Link to post
Share on other sites

Posted (edited)

Well, I didn't touched VB at all and I'm not familiar with its syntax, but a working example of this in C++ should be like this:

typedef long (WINAPI *MouseMoveProc)(long nX, long nY, long nSpeed);

int _tmain(int argc, _TCHAR* argv[])
{
HMODULE hModule = LoadLibrary("AutoItX3.dll");
if (hModule == NULL)
{
MessageBox(NULL, "Error 1", "", MB_OK);
return 0;
}
MouseMoveProc MouseMove = (MouseMoveProc)GetProcAddress(hModule, "AU3_MouseMove");
if (MouseMove == NULL)
{
MessageBox(NULL, "Error 2", "", MB_OK);
return 0;
}
MouseMove(10, 10, 0);
return 0;
}
Edited by D4RKON3

Share this post


Link to post
Share on other sites

Posted

Thank you. It looks promising. I've already found all the API for VB.NET and am trying to load the functions now. I'll post back with my results.

Thank you, again. :)

Share this post


Link to post
Share on other sites

Posted

AC130, did you resolve this with the API for VB.NET as you mention in your last post? In other words, are you now able to call AutoIT commands directly in your Visual Basic solution? If so, do you mind sharing this? I am basically in the exact situation you were in when you started this discussion. However, I am fairly new to this & need a lot of guidance right now.

I am trying to create an VB application that use mostly AutoIT commands & am unsure of how exactly to begin.

Any help you can offer would be much appreciated.

Thanks a ton! :bye:

Share this post


Link to post
Share on other sites

Posted (edited)

Dowload: AutoItX3Dll Auto Register AutoRegisterAutoItX3Dll: Click here

Automatic install dll file to system32 directory and registering dll to use.

You'll see dll lib add in the reference com. You must Import Class lip on the class form.

Example: VB.NET run calculator application.

Imports AutoItX3Lib
Public Class Form1
Private oAutoItX As New AutoItX3
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
     oAutoItX.Run("calc.exe")
End Sub
End Class
Edited by Laymanball

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.