Running AutoIt3 Scripts in VB 2010

2019-08-29 20:36发布

问题:

I am fairly new to this, so pardon me if I am asking a silly question.

I created an application in 2006 that calculates bottom-hole pressure. Basically, it takes the user-inputs, calls a secondary application called REFPROP, and delivers the REFPROP results back to my application to continue the calculations. Using AutoIt, I created a temp file with user inputs & another with REFPROP outputs. Since REFPROP was a cmd prompt application, the process was fairly simple.

Now, the REFPROP I incorporated into my application is outdated & the new version has a GUI that requires more than cmd prompts. I would like to use AutoIt3 again, but this time to create a temp Excel file for user inputs, run REFPROP, create a temp output file, and return to my application.

I am somewhat lost as I am unable to run AutoIt scripts within my VB 2010 environment right now. My current plan is to create & compile AutoIt scripts to open & run REFPROP with user inputs, but I am not sure of how exactly to go about that... Does anyone have any idea of the best way to go about this?

Any help with this would be so much appreciated.

Thanks!

回答1:

It's actually very easy. Take a look at the references on the AutoIt script forums and in the manual. Start by working with recordings and move from there.

Use regsvr32 AutoItX3.dll and register the DLL.

Then add a project reference inside the solution

Then run some code like this (This is in C#, but the concept works the same)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AutoItX3Lib;

namespace ConsoleApplication2 {
    class Program {
        static void Main(string[] args) {
            AutoItX3Class au3 = new AutoItX3Class();
            while( true ) {
                Console.WriteLine("({0}, {1})" , au3.MouseGetPosX() , au3.MouseGetPosY());

            }
        }
    }
}