AutoItObject UDF

349 posts in this topic




Posted

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.

Share this post


Link to post
Share on other sites

Posted

I...I...I...don't know what to say... :mellow:

Share this post


Link to post
Share on other sites

Posted

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

Share this post


Link to post
Share on other sites

Posted

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?

Share this post


Link to post
Share on other sites

Posted

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

Share this post


Link to post
Share on other sites

Posted

That, is so awesome! Great release!

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

Share this post


Link to post
Share on other sites

Posted

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

Share this post


Link to post
Share on other sites

Posted

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

Congratulations and well done, this is awesome!

Share this post


Link to post
Share on other sites

Posted

Awesome :mellow:

Finally, objects!

Great work!

Share this post


Link to post
Share on other sites

Posted

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

Finally,

THANK YOU.

Share this post


Link to post
Share on other sites

Posted (edited)

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?

; ===============================================================================================================================
; 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.

#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

Share this post


Link to post
Share on other sites

Posted

I love you guys.

Share this post


Link to post
Share on other sites

Posted

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:

Share this post


Link to post
Share on other sites

Posted

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?

Share this post


Link to post
Share on other sites

Posted (edited)

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

Share this post


Link to post
Share on other sites

Posted

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:

Share this post


Link to post
Share on other sites

Posted

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}")

Share this post


Link to post
Share on other sites

Posted

I just jizzed in my pants Posted Image

mLipok likes this

Share this post


Link to post
Share on other sites

Posted

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

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