Jump to content

How do I declare an AutoIt object in VC++ .NET?


janus96
 Share

Recommended Posts

Now that I know how to get AutoIt to work under MFC, I'd like to move on to .NET.

I've searched this forum back to the year 2005. The closest I could find was an example in C#:

http://www.autoitscript.com/forum/index.php?showtopic=26042

It gave me some ideas, e.g.

using namespace AutoItX3Lib;

.............

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

and some other combinations, but none of them would work.

The project was a CLR/Windows Forms Application project. I've added Interop.AutoItX3Lib.1.0 to the reference.

Any help will be greatly appreciated. Thanks.

Link to comment
Share on other sites

It gave me some ideas, e.g.

using namespace AutoItX3Lib;

.............

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

and some other combinations, but none of them would work.

The project was a CLR/Windows Forms Application project. I've added Interop.AutoItX3Lib.1.0 to the reference.

Any help will be greatly appreciated. Thanks.

Let me add that from the Object Browser in Visual Studio I can see clearly the objects and functions of AutoItXLib. A screen capture is attached here. I think if I can be shown the syntax of object declaration and instanciation, I'll be able to get it going. Thanks.

Posted Image

Link to comment
Share on other sites

Ok, I got it to work. The coding is much cleaner than using dll in VC++. I love it.

AutoItX3Lib::AutoItX3Class^ aix3c = gcnew AutoItX3Lib::AutoItX3Class();

aix3c->MouseMove(-500,500,10);

However, in compiling, the compiler asked that "gcnew" be used, instead of "new". "gcnew", however, returns a pointer. Such is the reason why "->" must be used instead of ".". It's ok with me, but I wonder if someone can tell me how to get around this, so that I can get an object instead a pointer to an object. Thanks.

Link to comment
Share on other sites

gcnew is a keyword to allow the object to be garbage collected (gc). You are supposed to use a pointer when using objects in this nature. When you use .Net, every "object" is a reference type. Your variables are all pointers (references) to the objects. You cannot directly hold an object in .Net, only a reference to it.

This is how the garbage collector knows how to clean up, when all references to the object expire.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...