daluu

Using AutoIt in VB.NET

9 posts in this topic

This is a repost from http://www.d3scene.com/forum/development/82572-tutorial-use-autoit-vb-net.html that I came across today. I don't think it is cross posted here already doing a search for .NET related stuff here. Please move to appropriate forum if posted to wrong one (e.g. ActiveX/COM Help and Support (AutoItX) or General Help and Support). If already duplicated here, please delete.

Thought it deserves a copy here w/o having users to register over at the source forum to see it. I've yet to personally try the example though, plan to soon. Perhaps a good idea to later on provide the C# version of code snippet for comparison purposes.

Original post info modified for clarity:

 

In this tutorial you will learn how to use Autoit functions in VB.NET(and C#)

 
Things you need :
 
Microsoft Visual Basic.NET(or C#) 2010 Express (or any other versions)
AutoitX Library which is in attachments
 
Create a new (VB).NET project (e.g. Windows Forms Application) and add a button in your form
Go to your project references and add AutoitX Library
Now go to your form and add a button
Go to codes section and fill in sample code below to create a button that will launch notepad.exe then enter text into it and finally close notepad as a demo.
 
Now test your program, you will see the exciting result
 
Q.Whats the point of using Autoit in VB.NET ?
A.As you know Autoit is single threaded, but when you use it in another language like VB.NET you can use all .NET API's combine Autoit functions with Multi threading support,using microsoft visual form designer and ... (a lot of others!)
 
Imports AutoItX3Lib

Public Class MainForm
    Dim AutoitCommand As New AutoItX3

    Private Sub StartButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartButton.Click
   AutoitCommand.Run("notepad.exe")
       AutoitCommand.WinWait("Untitled - Notepad")
       AutoitCommand.Send("This text sent to notepad by autoit functions{ENTER}Have Fun")
       AutoitCommand.Sleep(1000)
       AutoitCommand.WinKill("Untitled - Notepad")
       End
    End Sub
End Class

AutoItX3_x86.rar

AutoItX3_x64.rar

1 person likes this

Share this post


Link to post
Share on other sites



Hi 

daluu, Although the code above is not working for me, but i was shocked because, this is what i wanted. Thanks a lot.  I have tested lot of other functions. All are working. except this. May be my notepad is the problem. And i can only see a few autoit functions in vb.net. Where are the others ?. Please tell me that what should i do with AutoItX3_x86.rar file. 

My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Share this post


Link to post
Share on other sites

Hi 

daluu

Please tell me how to tie up this AutoitX with Python.


My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Share this post


Link to post
Share on other sites

Hi daluu, 

I am almost there, but i need ProgID or CLSID of autoitX3. How to find it


My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Share this post


Link to post
Share on other sites

Hi daluu,

It worked. Thanks a lot. An artcle in that link says that every info about COM in python is in Oreilly's Python Programming on Win32

by Mark Hammond. I have that book. After reading that chapter, i can easily connect AutoIt COM in python. Thanks a lot.


My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Share this post


Link to post
Share on other sites

What am I seeing here :shocked:, Using AutoItX COM Library in VB.NET instead of using VB.NET's own abilities :think:?


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

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

  • Similar Content

    • Luigi
      By Luigi
      Greetings, someone can give a exemple, how send a error from a C#'s dll to AutoIt?
      I use this line, to send an error... but, I want get a error code In AutoIt with macro @error, it's possible?
       
      throw new ArgumentException("arquivo map não existe", "value" ); In this way, work, I know ther are error, but, @errror always is zero.
      I don't want this, I want a number as error code.
      Can you help me?
       
      Best regards
    • ptrex
      By ptrex
      WHAT : is .NET Common Language Runtime (CLR) Framework
      The Common Language Runtime (CLR) is a an Execution Environment . Common Language Runtime (CLR)'s main tasks are to convert the .NET Managed Code to native code, manage running code like a Virtual Machine, and also controls the interaction with the Operating System.
      As part of Microsoft's .NET Framework, the Common Language Runtime (CLR) is managing the execution of programs written in any of several supported languages. Allowing them to share common object-oriented classes written in any of the languages.
      HOW : To access the CLR environment you need to create an Appdomain Object - _CLR_GetDefaultDomain()
      An AppDomain provides an isolated region in which code runs inside of an existing process.
      Application domains provide an isolation boundary for security, reliability, and versioning, and for unloading assemblies. Application domains are typically created by runtime hosts, which are responsible for bootstrapping the common language runtime before an application is run.
      WHEN : Would you use CLR Runtime Hosts
        1. To access  .NET Class Libraries :
      System System.Collections System.Data System.Drawing System.IO System.Text System.Threading System.Timers System.Web System.Web.Services System.Windows.Forms System.Xml   2. Accessing custom build .Net Assemblies :
        Some Examples (but there are a ton out there)
      AutoItX3 - The .NET Assembly for using AutoItX JSonToXML libr. XMLRPC Libr. .NETPDF libr. .NETOCR Libr WInSCP Libr.  ...   3. To Compile .Net Code into an Assembly
        4. To Run C# or VB.net Code
        5. To Mix AU3 and .Net functionality in your Application
       
      WHERE :  To find documentation about CLR
      First of all you can find a lot on MSDN and here  : Post 4 & Post 6
       
      EXAMPLES : Multiple examples included in Zip !!
      Example : “System.Text.UTF8Encoding”

      Example : “System.IO.FileInfo”

      Example : “System.Windows.Forms”

      Example : AutoItX3 Custom .NET Assembly AutoItX

      Example : Compile Code C# and Code VB

      Example : Compile Code C# at Runtime

       
      WHO : Created the CLR.au3 UDF
      All credits go to : Danyfirex / Larsj / Trancexx  / Junkew
       
      TO DO : The library is still Work in Process …
      (Some of the GUI Controls are not yet working as expected...)
      Anyone is free to participate in contributing to get the bugs resolved and to expand the CLR.au3 functionality ...
      Enjoy !!
      DOWNLOADS :  (Last updated) 
      - added CLR Constants.au3 - Danyfirex
          - Global Constants added (Magic numbers)
      - added .NET CLR CreateObject vs ObjCreate Example.au3 - Junkew
               • 2 approaches give the same result (only valid for COM Visible Assembly)
               • Includes a function that shows you which Assembly Classes are COM Visible
      - added .Net Conventional COM Objects Examples - ptrex
      - added .NET CLR CreateComInstanceFrom Example - Danyfirex
          - You can use it for Regfree COM Assembly Access
          - System.Activator has 4 methods :
              • CreateComInstanceFrom : Used to create instances of COM objects.
              • CreateInstanceFrom : Used to create a reference to an object from a particular assembly and type name.
              • GetObject : Used when marshaling objects.
              • CreateInstance : Used to create local or remote instances of an object.
      - added .NET Access SafeArrays Using AccVarsUtilities Example - LarsJ
      - added SafeArray Utilities functions in Includes - LarsJ 
      - added .NET Access Native MSCorLib Classes - System - ptrex
          Multiple System Class Examples :
               • System.Random
               •  System.DateTime
               •  System.Diagnostics.PerformanceCounter
               •  System.IO.FileInfo
               •  System.Int32
               •  System.Double
               •  System.Speech
               • System.Web
      - added Third Party Assembly Access - ptrex
               • WinSCP : https://winscp.net/eng/download.php
               • IonicZip : http://dotnetzip.codeplex.com/
       
      CLRv3a.zip
      .NET CLR Framework for AutoIT.pdf
    • breakbadsp
      By breakbadsp
      AutoIT AU3info doeas not detect all gui objects uniquely for .NET GUIs developed in C#.
      this is not working now i am using COM windows approach for this, But its very difficult.
      Please let me know if anyone has done it before.
    • 5ervant
      By 5ervant
      What's the best way to receive file from a desktop app?
      app.exe will execute a cmd with "au3file.exe /path/of/the/file.xml" and the au3file.exe will get and delete that. Or else? THE MOST IMPORTANT PART OF THE QUESTION
      And best way to transfer file to a desktop app?
      au3file.exe do a $_POST request and the app.exe MUST HAVE a local HTTP server that can receive $_POST, but it looks heavy 'cause the app must have a server such XAMPP. au3file.exe execute a cmd with "app.exe /path/of/the/file.xml" and the app.exe will now get that file and delete. Or else?