Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

AutoItObject UDF


  • Please log in to reply
340 replies to this topic

#1 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 19 February 2010 - 06:39 PM

*
POPULAR

Posted Image
The AutoItObject team is proud to announce that the first version of our AutoItObject UDF is complete and ready to use.

The project page is located at [currently missing]
Please, report bugs and any other issues at our [currently missing], and not here.
An overview of all the functions can be found in the online documentation [currently missing] or in the offline .chm documentation file which is included with the [currently missing].
If Origo has problems providing the download, the current version will be mirrored here
The UDF requires the current AutoIt version v3.3.4.0!
Attached File  AutoItObject 1.2.8.2.exe   413.04KB   277 downloads
Attached File  AutoItObject 1.2.8.2.zip   239.04KB   4160 downloads

Please, leave your comments and experiences here.

Regards,
- trancexx
- ProgAndy
- monoceres
- Kip

Our work is published under the Artistic License 2.0

A copy of the FAQ to answer your most urgent questions right away: (can also be found at the online documentation:

Q. What is Object Orientation and why do I need it?
OO is a highly used programming paradigm that is widely used in many programming languages. In procedural programming (AutoIt, C, etc.) you pass around data to different functions. In OO however, you use objects that contains both the function and data. It's especially useful when dealing with larger projects and need to structure your code. OO also offers tools such as inheritance to save yourself from rewriting code.

Q. How does this work? AutoIt already has support for COM objects. What this library does is it creates dynamic com objects during runtime that executes AutoIt code.

Q. How does this affect my script performance wise? There is a minor speed difference between calling methods and calling functions directly. However the difference is minor and you'll probably never notice it. When execution reaches AutoIt code it continues at normal speed.

Q. Does the library support inheritance? Yes. _AutoItObject_Create() has an optional $parent parameter.

Q. What about multiple inheritance? No problems. Calls to _AutoItObject_Create() can be nestled.

Q. Why isn't it possible to pass arguments as ByRef to methods? This is a limitation within AutoIt. It's not possible to overcome this problem by directly calling the member functions, but that goes against the OO thinking and will not be covered here (use common sense).

Q. Why can't I use variables of ptr-type in arguments to methods? See previous answer.

Q. Can I use arrays as properties? Yes. However, it's slower than usual.

Q. Does this mean that the objects I create are available from other programs since they're actually COM-objects? No. The objects are created at runtime and for AutoIt's eyes only.

Q. My GUI freezes! Why and how do I fix it? All methods are essentially dllcallbacks. Unfortunately this means that messages are not processed while your methods are being executed. As long as you keep your main loop outside any method, you'll be fine.

Some helper-functions:
When using the Wrapper, this are some simple methods to get a return value from the resulting array.
Plain Text         
; #FUNCTION# ==================================================================================================================== ; Name...........: _AIOResult ; Description ...: Returns the return value of the Call to a WraperObject function ; Syntax.........: _AIOResult(Const $aResult [, $vError=0] ) ; Parameters ....: $aResult  - the resulting array ;                $vError     - [optional] value to be returned if result is no array (default: 0) ; Return values .: Success   - Returnvalue ($aResult[0]) ;                Failure     - $vError, @error set to 1 ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; ; =============================================================================================================================== Func _AIOResult(Const $aResult, $vError=0)     ; Author: Prog@ndy     If IsArray($aResult) Then Return $aResult[0]     Return SetError(1,0,$vError) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _AIOParam ; Description ...: Returns the parameter value of the Call to a WraperObject function ; Syntax.........: _AIOParam(Const $aResult, $iParam, $vError=0) ; Parameters ....: $aResult  - the resulting array ;                $iParam     - The parameterindex to return (0: result, 1: first parameter, 2: 2nd parameter, ...) ;                $vError     - [optional] value to be returned if result is no array (default: 0) ; Return values .: Success   - Parameter value ;                Failure     - $vError, @error set to 1 ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; ; =============================================================================================================================== Func _AIOParam(Const $aResult, $iParam, $vError=0)     ; Author: Prog@ndy     If UBound($aResult)-1 < $iParam Then Return SetError(1,0,$vError)     Return SetExtended($aResult[0], $aResult[$iParam]) EndFunc

Edited by ProgAndy, 10 September 2012 - 02:37 PM.

  • jaberwacky, Decipher, yahaosoft and 2 others like this
*GERMAN* Posted Image [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes







#2 JohnOne

JohnOne

    John

  • Active Members
  • PipPipPipPipPipPip
  • 12,889 posts

Posted 19 February 2010 - 06:53 PM

This looks really interesting, and although Its way above my head at the moment, I have been following the thread, and really looking forward to giving it a try.

Thank you very much for sharing your hard work and time.

AutoIt Absolute Beginners Require a serial
 
 
OMG! Women are the cows of people.


#3 Alek

Alek

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 330 posts

Posted 19 February 2010 - 06:56 PM

I...I...I...don't know what to say... :mellow:
Never fear, I is here.

#4 Kip

Kip

    Into the JavaScript

  • Active Members
  • PipPipPipPipPipPip
  • 1,690 posts

Posted 19 February 2010 - 08:35 PM

There is an examples folder in the download package by the way. That should give you an idea how it all works.

#5 martin

martin

    ~~\o/~~~/0\=¬''~~~

  • MVPs
  • 7,321 posts

Posted 19 February 2010 - 10:02 PM

A huge thanks to the AutoItObject team. :mellow:

Lots of us have been waiting to play with this; at first glance you have made it simple to use.

It might be worth mentioning in the first post that the latest production release is required. (To allow the long strings used for the dll.)

Couldn't _AutoItObject_StartUp() be included in AutoitObject.au3 and _AutoItObject_Shutdown() be added to __Au3Obj_OleUninitialize?
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

#6 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 21,743 posts

Posted 19 February 2010 - 10:06 PM

Guys and Gal,

Thank you for the all work this represents - although I am sure it was a lot of fun as well. :mellow:

Once I get my head around this I am sure I will have lots of questions - at the moment I just stand in awe of what you have done.

Thanks again,

M23
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
Date_Time_Convert - Easily convert date/time formats, including the language               GUIListViewEx - Insert, delete, move, drag, sort and edit ListView items

#7 AlmarM

AlmarM

    Programming my way.

  • Active Members
  • PipPipPipPipPipPip
  • 1,694 posts

Posted 19 February 2010 - 11:37 PM

That, is so awesome! Great release!

I AM going to take a closer look on this later on. :mellow:

Minesweeper

A minesweeper game created in autoit, source available.

 

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

 

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.


#8 Beege

Beege

    Universalist

  • MVPs
  • 895 posts

Posted 19 February 2010 - 11:55 PM

YES! Its here! Great job you guys. Can't wait to start playing around with this. VERY EXCITING!! :mellow:

#9 JRowe

JRowe

    Chasing the white rabbits

  • Active Members
  • PipPipPipPipPipPip
  • 1,765 posts

Posted 20 February 2010 - 12:12 AM

For this, English doesn't have enough expression. Magnifiqué! Meraviglioso!

Congratulations and well done, this is awesome!

#10 NerdFencer

NerdFencer

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 284 posts

Posted 20 February 2010 - 03:30 AM

Awesome :mellow:
Finally, objects!

Great work!

#11 ivan

ivan

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 402 posts

Posted 20 February 2010 - 03:33 AM

I cannot believe my eyes! Amazing, outstanding, and with a help file included. I praise you guys, you excel at scripting.

Finally,
THANK YOU.

#12 NerdFencer

NerdFencer

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 284 posts

Posted 20 February 2010 - 04:53 AM

I love objects, but having to declare them like _SomeBulkyFunctionName(...) grates on my nerves (as I am used to C++ style classes), so I wrote a small function "_ObjCreate" to create objects for AutoItObject with somewhat cleaner syntax. Here it is for anybody else interested in using it.

Is something more native feeling a possibility for the future?

AutoIt         
; =============================================================================================================================== ; Creates an object using AutoItObject from a string ; Fist, define a class name by saying ":Class ClassName;" ; All commands must end with a semicolon. ; Define variables by stating "VariableName=Value;" or simply "VariableName;" to create an empty string ; Define functions by stating "FunctionName();" ;   In AutoIt, this will call a function named "_ClassName_FunctionName" ;   Destructors are created similarly as "~FunctionName()" ; By default, all data members are public, but you can change the current setting by using... ;   ":Public;", ";Private", or ":ReadOnly;" ; Enjoy, ; -NerdFencer ; =============================================================================================================================== Func _ObjCreate($sText)     Local $iScope = $ELSCOPE_PUBLIC     Local $sName = "", $oObject = _AutoItObject_Class(), $sTmp     $oObject.Create()     $sText = StringSplit($sText,";",1)     For $i=0 To $sText[0]         ;Whitespace         While 1             If StringLeft($sText[$i],1)==" " Or StringLeft($sText[$i],1)==@TAB Then                 $sText[$i] = StringTrimLeft($sText[$i],1)             Else                 ExitLoop             EndIf         WEnd         ;Operators         If StringLeft($sText[$i],1)==":" Then             Switch StringLeft($sText[$i],4)                 Case ":Cla"                     $sName = StringTrimLeft($sText[$i],7)                 Case ":Pub"                     $iScope = $ELSCOPE_PUBLIC                 Case ":Pri"                     $iScope = $ELSCOPE_PRIVATE                 Case ":Rea"                     $iScope = $ELSCOPE_READONLY             EndSwitch             ContinueLoop         EndIf         ; Functions         If StringInStr($sText[$i],"(")>0 Then             $sTmp = StringLeft($sText[$i],StringInStr($sText[$i],"(")-1)             If StringLeft($sTmp,1)=="~" Then                 $oObject.AddDestructor("_"&$sName&"_"&StringTrimLeft($sTmp,1))             Else                 $oObject.AddMethod($sTmp, "_"&$sName&"_"&$sTmp)             EndIf             ContinueLoop         EndIf         ; Variables         If StringInStr($sText[$i],"=")>0 Then             $sTmp = StringReplace(StringLeft($sText[$i],StringInStr($sText[$i],"=")-1)," ","")             $oObject.AddProperty($sTmp, $iScope, Execute(StringTrimLeft($sText[$i],StringInStr($sText[$i],"="))))             ContinueLoop         EndIf         If StringLen($sText[$i])>0 Then             $sTmp = StringReplace($sText[$i]," ","")             $oObject.AddProperty($sTmp, $iScope, '')             ContinueLoop         EndIf     Next     Return $oObject.Object EndFunc

And a modified example of the MessageBox example using this style declaration.
AutoIt         
#include "AutoitObject.au3" #include "parse.au3" Opt("MustDeclareVars", 1) ; Declare the MessageBox class ; Could also be done like this... ; Global $Class_MsgBox = ':Class MsgBox;Title="Something";Text="Some Text";Flag=64 + 262144;MsgBox();~Destructor();' Global $Class_MsgBox = _ ':Class MsgBox;' & _ '   Title="Something";' & _ '   Text="Some Text";' & _ '   Flag=64 + 262144;' & _ '   MsgBox();' & _ '   ~Destructor();' ; Error monitoring Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc") ; Initialize AutoItObject _AutoItObject_StartUp() ; Create Object Global $oObject = _ObjCreate($Class_MsgBox) ; Set some property $oObject.Title = "Hey" ;Display messagebox $oObject.MsgBox() ; Relese $oObject = 0 ; That's it! Goodby Func _MsgBox_MsgBox($oSelf)     MsgBox($oSelf.Flag, $oSelf.Title, $oSelf.Text) EndFunc   ;==>_Obj_MsgBox Func _MsgBox_Destructor($oSelf)     ConsoleWrite("!...destructing..." & @CRLF) EndFunc Func _ErrFunc()     ConsoleWrite("! COM Error !  Number: 0x" & Hex($oError.number, 8) & "   ScriptLine: " & $oError.scriptline & " - " & $oError.windescription & @CRLF)     Return EndFunc   ;==>_ErrFunc

Great work ProgAndy!
Thanks for making this possible :mellow:

Edited by NerdFencer, 20 February 2010 - 04:56 AM.


#13 BillLuvsU

BillLuvsU

    Useless Member

  • Active Members
  • PipPipPipPipPipPip
  • 1,561 posts

Posted 20 February 2010 - 07:58 AM

I love you guys.

Posted Image

Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

#14 trancexx

trancexx

    Queen F. Elizabeth MCXI

  • Active Members
  • PipPipPipPipPipPip
  • 6,245 posts

Posted 20 February 2010 - 08:24 AM

A huge thanks to the AutoItObject team. :(

Lots of us have been waiting to play with this; at first glance you have made it simple to use.

It might be worth mentioning in the first post that the latest production release is required. (To allow the long strings used for the dll.)

Couldn't _AutoItObject_StartUp() be included in AutoitObject.au3 and _AutoItObject_Shutdown() be added to __Au3Obj_OleUninitialize?

Optional parameters for _AutoItObject_StartUp() wouldn't make sense then. This way full control of type of initialization is given to the user.
Shutting it down is something that you don't have to do at all.
You will see that it's simple at any glance. :mellow:

          ......       ......
        .:oOOOOo:.   .:oOOOOo:.
      .:oOO:'':Oo:. .:oO:'':OOo:.
     .:oO:      'Oo:oO'      :Oo:.
     :oO:         'o'   
      :Oo:
     :oO:                     :Oo:
     ':oO:     OT9AO0IEDrk   :Oo:'
      ':oO:                 :Oo:'
        ':oO.             .Oo:'
          ':oO
.         .Oo:'
            ':oO.     .Oo:'
              ':oO. .Oo:'
                'oO:Oo'
                  'o' :kiss:



 

.
eMyvnE


#15 Beege

Beege

    Universalist

  • MVPs
  • 895 posts

Posted 20 February 2010 - 09:49 AM

I'm getting confused with inheritance. Going off of the ITaskbarList example that was given, If I wanted to get the ITaskbarList2 interface that inherits from ITaskbarList, am I suppost to use the _AutoItObject_Create() function?

#16 trancexx

trancexx

    Queen F. Elizabeth MCXI

  • Active Members
  • PipPipPipPipPipPip
  • 6,245 posts

Posted 20 February 2010 - 09:57 AM

I'm getting confused with inheritance. Going off of the ITaskbarList example that was given, If I wanted to get the ITaskbarList2 interface that inherits from ITaskbarList, am I suppost to use the _AutoItObject_Create() function?

If some interface inherits from some other that means that its vtable is richer for the new members. In your case you just append that new method that ITaskbarList2 Interface introduces to tagITaskbarList.

edit: see DirectShow example where all wrapped interfaces inherits from IDispatch (that inherits from IUnknown).

Edited by trancexx, 20 February 2010 - 10:01 AM.

          ......       ......
        .:oOOOOo:.   .:oOOOOo:.
      .:oOO:'':Oo:. .:oO:'':OOo:.
     .:oO:      'Oo:oO'      :Oo:.
     :oO:         'o'   
      :Oo:
     :oO:                     :Oo:
     ':oO:     OT9AO0IEDrk   :Oo:'
      ':oO:                 :Oo:'
        ':oO.             .Oo:'
          ':oO
.         .Oo:'
            ':oO.     .Oo:'
              ':oO. .Oo:'
                'oO:Oo'
                  'o' :kiss:



 

.
eMyvnE


#17 Beege

Beege

    Universalist

  • MVPs
  • 895 posts

Posted 20 February 2010 - 10:30 AM

If some interface inherits from some other that means that its vtable is richer for the new members. In your case you just append that new method that ITaskbarList2 Interface introduces to tagITaskbarList.

edit: see DirectShow example where all wrapped interfaces inherits from IDispatch (that inherits from IUnknown).


Ok thanks for the response. :mellow:

#18 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 20 February 2010 - 10:41 AM

The problem is, you rarely find the vTables with the correct order. Here are those for all ITaskbarlist-interfaces (but without parameter-types)
Global Const $ITaskbarList = "ptr lpVtbl" Global Const $ITaskbarListVtbl = "ptr QueryInterface; ptr AddRef; ptr Release; ptr HrInit; ptr AddTab; ptr DeleteTab; ptr ActivateTab; ptr SetActiveAlt;" Global Const $ITaskbarList2Vtbl = $ITaskbarListVtbl & 'ptr MarkFullscreenWindow;' Global Const $ITaskbarList3Vtbl = $ITaskbarList2Vtbl & 'ptr SetProgressValue; ptr SetProgressState; ptr RegisterTab; ptr UnregisterTab; ptr SetTabOrder; ptr SetTabActive; ' & _     'ptr ThumbBarAddButtons; ptr ThumbBarUpdateButtons; ptr ThumbBarSetImageList; ptr SetOverlayIcon; ptr SetThumbnailTooltip; ptr SetThumbnailClip;' Global Const $ITaskbarList4Vtbl = $ITaskbarList3Vtbl & 'ptr SetTabProperties;'  Global Enum _ ;STPFLAG     $STPF_NONE                       = 0x00000000, _     $STPF_USEAPPTHUMBNAILALWAYS      = 0x00000001, _     $STPF_USEAPPTHUMBNAILWHENACTIVE  = 0x00000002, _     $STPF_USEAPPPEEKALWAYS           = 0x00000004, _     $STPF_USEAPPPEEKWHENACTIVE       = 0x00000008 Global Enum _ ; TBPFLAG   $TBPF_NOPROGRESS = 0, $TBPF_INDETERMINATE = 0x1, $TBPF_NORMAL = 0x2, $TBPF_ERROR = 0x4, $TBPF_PAUSED = 0x8 Global $CLSID_TaskBarlist = _AutoItObject_CLSIDFromString("{56FDF344-FD6D-11D0-958A-006097C9A090}") Global $IID_ITaskbarList = _AutoItObject_CLSIDFromString("{56FDF342-FD6D-11d0-958A-006097C9A090}") Global $IID_ITaskBarlist2 = _AutoItObject_CLSIDFromString("{602D4995-B13A-429b-A66E-1935E44F4317}") Global $IID_ITaskBarlist3 = _AutoItObject_CLSIDFromString("{ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf}") Global $IID_ITaskBarlist4 = _AutoItObject_CLSIDFromString("{c43dc798-95d1-4bea-9030-bb99e2983a1a}")

*GERMAN* Posted Image [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

#19 James

James

    Universalist

  • MVPs
  • 10,337 posts

Posted 20 February 2010 - 07:00 PM

I just jizzed in my pants Posted Image
  • mLipok likes this

#20 Beege

Beege

    Universalist

  • MVPs
  • 895 posts

Posted 20 February 2010 - 07:43 PM

Oh this is great! Thanks so much ProgAndy! :mellow:




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users