Sign in to follow this  
Followers 0
mozart90

How to use a self compiled VB6 dll with AutoIt

6 posts in this topic

Hi,

This is a small Tutorial of how to build a DLL in VB and use it in Autoit.

Some time ago I was searching how to integreate a small VB6 Function as dll in Autoit.

The problem was: Nobody could tell me how to do.

Now, here is the answer :D

First of all you need Visual Basic. (I tried this with V6)

1.) In VB open a new Project. Select ActiveX Dll.

2.) Rename the 'Class1' in let's say: 'Myclass'

3.) Insert the desired Code: For Example

'---------------------------------------------------------------------------
' VB Code
'---------------------------------------------------------------------------
'In this examle an perhaps an Api delaration which is called in the following function 

 Private Declare Function GetWindowsDirectory Lib "KERNEL32" _
      Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, _
      ByVal nSize As Long) As Long

' Actually the function itself - Just output the Windows Dir 
   
Public Function WinDir() As String
      Dim sDirBuf As String * 255
      StrLen = GetWindowsDirectory(sDirBuf, 255)  ' Call the api function 
      WinDir = Left$(sDirBuf, StrLen)  ' that's what is returned 
End Function

4.) Then deside for a Projectname. Goto Project - Properties in VB and enter a Projectname. Lets say 'mydll'

(This is the proposed Filename for the dll too)

5.) Compile the Project. You have finished in VB

6.) Register you new dll with 'regsvr32.exe mydll.dll'

7.) Use the dll in Autoit as following:

;---------------------------------------------------------------------------
; Autoit Code; needs beta I think  
;---------------------------------------------------------------------------

$obj= objcreate("mydll.myclass");create the object 
$ret= $obj.WinDir ;call the function
msgbox (0,"From Call",$ret) ' show the guy

Thats all. I know there is an easier way to get the system directory - but it's just an example :D

So have fun with a closer interaction of VB and Autoit.

Greetings Mozart90

Share this post


Link to post
Share on other sites



Thanks Mozart :D ...

But...

What's VB? :D (J/K)


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Pretty cool...here is also an example of creating VB6 ActiveX control and using it in AutoIt.

See this and I also added another function "Caption" which changes the text.

Attached is .ocx file and autoit script (you must run 'regsvr32.exe animation.ocx' to use)

test.zip

Edited by livewire

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Here is a VB Button that you can change the color of.

Does anyone know how to get events (clicks) from this button?

(you must run 'regsvr32.exe VBButton.ocx' to use)

('regsvr32.exe /u VBButton.ocx' unregisters the control)

-Livewire

VBButton.zip

Edited by livewire

Share this post


Link to post
Share on other sites

These are really nice! How do I do This in VB 2005 Express edition?


My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites

Pretty cool...here is also an example of creating VB6 ActiveX control and using it in AutoIt.

See this and I also added another function "Caption" which changes the text.

Attached is .ocx file and autoit script (you must run 'regsvr32.exe animation.ocx' to use)

In this example, how do I modify the activex control's properties using AutoIt script (like: 'Visible', 'ToolTipText', etc.)?

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
Sign in to follow this  
Followers 0