Jump to content
Sign in to follow this  
janus96

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

Recommended Posts

janus96

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.

Share this post


Link to post
Share on other sites
janus96

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

Share this post


Link to post
Share on other sites
janus96

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.

Share this post


Link to post
Share on other sites
janus96

Tested more functions. Everything now works right out of the box, even the ControlListView which I had trouble calling from Matlab. I think I'll do Matlab Automation from .NET.

Share this post


Link to post
Share on other sites
Sunaj
Richard Robertson

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.

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  

×