Jump to content

Recommended Posts

Posted

Hello everyone!

I am trying to get autoIT to work in my C# project, and have got as far as adding the AutoITX3Lib as a COM object. However.. now... I cannot figure out how to actually drill down to the methods of the library!

Doing something such as... "AutoItX3 myAuto = new AutoItX3();" impliments myAuto as an interface that I can then use to perform method calls correct? However, when trying to do so I get the error... "myAuto" is a 'field' but is used like a 'type' .. ? How can I drill down into the COM interface and actually call some of these methods?

It's quite frustrating and I couldn't find *anything* regarding working with the library as a COM object.. I am building my project using .NET 4 and visual studio 2010.

Thank you for your help everyone!

Posted (edited)

  On 11/25/2010 at 7:03 AM, 'Richard Robertson said:

Your declaration is correct. The error you posted is likely not occurring on the same line as the declaration right?

Yes, here I have a pastebin of the relevant code: http://pastebin.com/BjXqqDbe

Why can't i drill down into the method like this? What am I doing wrong?

I would just like to perform the ControlSend method but I can't for the life of me figure out how to do so. This is a C# project, and the AutoItX3Lib was added as a COM object (so an assembly was automatically created).

Please help :graduated:

**I would just like to add that I have tried a different approach, and basically used DLL import to wrap up and bring in the functions from the autoitx3.dll.

ex.. [DllImport("AutoItX3.dll", SetLastError = true, CharSet = CharSet.Auto)]

static public extern int AU3_ControlSend([MarshalAs(UnmanagedType.LPWStr)] string Title

, [MarshalAs(UnmanagedType.LPWStr)] string Text, [MarshalAs(UnmanagedType.LPWStr)] string Control

, [MarshalAs(UnmanagedType.LPWStr)] string SendText, int Mode);

and then in my main class i write:

void test = AutoItX3Declarations.AU3_ControlSend("Test Text","",etc...);

But get the error "cannot implicitly convert type 'void' to 'void'" .. I think i'm close to the solution but... why can't I call this? Arghh

AND.. if i use it this way: " AutoItX3Declarations.AU3_Send("Test Text", 1);" it says "AU3_Send" is a method but is used like a type... What the heck? I thought to run a static method from a static class you can just mention the class as the location and then go hard with the method? But it think's i'm using it as a type?

Edited by mavor
Posted

I see your problem. You are trying to call the functions when they are in a section of code that is actually executed. You are calling the functions correctly but they have to be called inside a function. I think you need to go learn basic programming.

Posted (edited)

You should learn the basics of C#.

exmaple scriptzor

namespace ConsoleApplication1
{
    class Program
    {

        public static AutoItX3Class AU3 = new AutoItX3Class();// create instance

        static void Main(string[] args)
        {
            AU3.WinWait("Untitled - Notepad");
            Console.WriteLine("Wait Finished");
            Console.Read();
        }
    }
}

Steve

EDIT: When you add the DLL make sure you change its Embed Interop Type property to False

Edited by Steveiwonder

They call me MrRegExpMan

  • 7 months later...
Posted (edited)

When i try to add dll to refrences i get error

"The module was expected to contain an assembly manifest"
. Do you know how to do it right?

I tried registring the dll with command

regsvr32.exe AutoItX3.dll

EDIT: hmm - wrong thread and it is magically started to work

Edited by evlo

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
  • Recently Browsing   0 members

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