Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
366 views
in Technique[技术] by (71.8m points)

autoit - How to use AutoItX in .NET (C#) without registering

How do I use AutoitX (OCX/ActiveX library) in a .NET C# application without registering it?

I would like to create an application with it without need to use administrator rights for installation.

I found some pages on MSDN like, Registration-Free Activation of COM Components: A Walkthrough about creating manifest files for DLL files. I tried it and did not succeed. So maybe it is possible and I created it wrongly. Unfortunately I lost the XML files so I can't post it here.

I also tried setting isolated and enable interop types in reference properties without success.

Is it possible to get AutoItX working in C# without need for registering? If so, how do I do it?

I think it should be possible to use as a DLL and not an OCX, but I don't know how exactly to do it in C#.

Currently, I use it like:

AutoItX3Lib.AutoItX3 autoit = new AutoItX3Lib.AutoItX3();
autoit.AutoItSetOption("WinTitleMatchMode", 2);

etc. So if I would go for direct DLL calls, how would I do it then?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In your C# project from Visual Studio, just go to Reference -> Add Reference -> Browse to your AutoIt dll and you're done. There's no need to register it seperately. But using this method you have to register.

A better way is to use the DLL directly, with [DllImport] statements. Here is a sample class that you can use: http://www.autoitscript.com/forum/topic/72905-c-use-of-the-dll-some-idears-for-you/

It defines functions like this:

[DllImport("AutoItX3.dll", SetLastError = true, CharSet = CharSet.Auto)]
static public extern int AU3_MouseUp([MarshalAs(UnmanagedType.LPStr)] string Button);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...