tags:

views:

200

answers:

2

Hi

I am trying to use AutoIT within a C# application in the following way:

au = new AutoItX3Lib.AutoItX3Class();
.
.
.
.
au.WinMenuSelectItem("MySoftware", "", "&File", "&Open");

On compiling this I get the following error:
Error 1 No overload for method 'WinMenuSelectItem' takes '4' arguments

Going by the definition of WinMenuSelectItem (http://www.autoitscript.com/autoit3/docs/functions/WinMenuSelectItem.htm) I am not sure how I go about fixing this.

Thanks

A: 

That document is only tangentially relevant to you. You're using a .NET wrapper around a COM object - you need to find out what the interface is to that wrapper.

The problem is exactly what the compiler is telling you it is...there's probably no overload for this version of that method that takes 4 arguments.

If you're using Visual Studio, Intellisense will tell you what parameters are expected...or you can use the "Object Browser" (right click on the AutoItX3Lib reference in your project).

If you're not using Visual Studio, Red Gate Reflector is a free tool that will inspect the assembly for you. You could use that to figure out what parameters are expected.

Joseph
+2  A: 

Try adding empty strings for the remaining parameters.

au.WinMenuSelectItem("MySoftware", "", "&File", "&Open", "", "", "", "", "");
aphoria
When using AutoItX wrapper, you must provide 'something' for the optional arguments, in this case, empty strings will work.
JohnForDummies