Jump to content

OOP Extender v0.3 Stable - Real object oriented programming with AutoIt


minxomat
 Share

Recommended Posts

Seems to work fine.

Initial remarks/notes/questions:

I see there is a second script created, can your UDF exit the initial script as it does not seem to be needed?

Is there a way to suppress the Console window that appears in compiled script?

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

I see there is a second script created, can your UDF exit the initial script as it does not seem to be needed?

Is there a way to suppress the Console window that appears in compiled script?

Re: First question:

Not when the actual script uses the console. It needs to read the running std stream to work correctly. If it would exit immediately, other users would only be able see the console output when the generated script exits (i.e. not real-time). But,

Re: Sec. q.:

Yes, didn't think about that. I'll add an option for that. (Or rather auto-detect if the user's script even uses the console at all).

Edited by minxomat

I will answer every single PM, and you are free to ask anything anytime.

Link to comment
Share on other sites

Is there anything that script authors would need to keep in mind when using this library? Any best practices that you recommend?

My goal is to keep this as indestructible (and fool-proof) as possible (partly because I use it myself). So instead of recommending best practices, I want to fix any issue you / others might come across. So if you find one - or want something new as a feature, use the issue tracker. If sometime in the distant future this enters v1.0+, I might create some in-depth pages on the wiki.

There are definitely a lot of bug fixes and features coming. :) 

I will answer every single PM, and you are free to ask anything anytime.

Link to comment
Share on other sites

@Chimp messaged me some problems he had with the OOPE. This told me two things: I need to extend the tutorial and that there are some bigger bugs in this "UDF". I've documented the relevant issues in the tracker and the fixes will come in v0.3 (which in turn will be coming sooner than thought, within this week even).

So thanks Chimp for testing and reporting!

I will answer every single PM, and you are free to ask anything anytime.

Link to comment
Share on other sites

So... Why would one choose this over AutoItObject?

I only ever used this once in my life. The fact that you need an auxiliary binary file (the DLL) disqualifies it for me. This here is native AutoIt. Of course, your mileage may vary. I won't get into a discussion about it here :) .

I will answer every single PM, and you are free to ask anything anytime.

Link to comment
Share on other sites

I only ever used this once in my life. The fact that you need an auxiliary binary file (the DLL) disqualifies it for me. This here is native AutoIt. Of course, your mileage may vary. I won't get into a discussion about it here :) .

You mean that optional file you don't actually use? If you don't want to use AO then fine, but don't lie about it.

Link to comment
Share on other sites

I will answer every single PM, and you are free to ask anything anytime.

Link to comment
Share on other sites

Released 0.3 Stable

+>21:44:52 Starting AutoIt3Wrapper v.15.920.938.0 SciTE v.3.6.0.0   Keyboard:00000409  OS:WIN_7/  CPU:X64 OS:X64    Environment(Language:0409)
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\Owner\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\Owner\AppData\Local\AutoIt v3\SciTE 
>Running:(3.3.14.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\Owner\Downloads\AutoIt-OOP-Extender-0.3\AutoIt-OOP-Extender-0.3\Examples\01 Simple Class.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
!> $oTest wants to be a Test object, but there is no class with that name!
!>21:44:52 AutoIt3.exe ended.rc:75
+>21:44:52 AutoIt3Wrapper Finished.

also, why not place the #include-once on top in OOPE.au3

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

... This AutoIt OOP Extender is very nice! I think that it can improve productivity and could simplify coding as well.
just played a bit with the example "06 Arrays of Objects.au3 so to beta testing it.
I've also modified it to make use of the "constructor with argument" way.
(Click on controls to write random chars in it, and use arrows to move the whole matrix)
here are 2 quick considerations:
1) if the listing is used letting it formatted as is, then it works, while if I Tidy the AutoIt listing, then it doesn't works anymore, arising an AutoIt error.
2) I've tried to use a call to a method of the class from within the constructor of the same class, but it doesn't work. (could be useful if this was allowed...).

See you later... I'm  keeping on playing still with this lovely toy ....

; 06 Arrays of Objects_mod.au3
#AutoIt3Wrapper_Run_AU3Check=n
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include '../OOPE/OOPE.au3'
Opt("GUIOnEventMode", 1)

;                 0  1  2   3   4   5   6  7
Local $aArgs[8]= [2, 2, 10, 10, 15, 15, 1, 1]
;            [0]    X position of the panel within the GUI
;            [1]    Y position of the panel within the GUI
;            [2]    nr. of columns
;            [3]    nr. of rows
;            [4]    width of each single controls
;            [5]    height of each single controls
;            [6]    horizontal distance between controls (space between controls)
;            [7]    vertical distance between controls
Local $aPlayers[$aArgs[2]*$aArgs[3]], $iStep1, $iStep2
Global $iIndex = 0

$hGUI = GUICreate("OOP Example")
GUISetOnEvent($GUI_EVENT_CLOSE, "_End")
#classdef <Player> $aPlayers from <$aArgs>
GUISetState()

MsgBox(0,"","Attempt to multicolor the matrix" & @CRLF & "in the constructor it did not work.", 5)

While 1 ; GUIGetMsg() <> -3
        $aPlayers[Random(0,UBound($aPlayers)-1,1)].SetBkColor(Random(0, 16777215, 1))
        $iStep1 = _IsPressed("27") - _IsPressed("25")
        $iStep2 = _IsPressed("28") - _IsPressed("26")
        If $iStep1 Or $iStep2 Then
        For $n = 0 To UBound($aPlayers)-1
            $aPlayers[$n].Move( $iStep1 * $aArgs[4], $iStep2 * $aArgs[5])
            $aPlayers[$n].SetBkColor(Random(0, 16777215, 1))
        Next
        EndIf
WEnd

Func Clicked()
    GUICtrlSetData(@GUI_CtrlId , Chr(Random(32, 127, 1)))
EndFunc

Func _End()
    Exit
EndFunc

#Region Class Player
    Local $iX, $iY, $iHandle

    Func _Player($aArgs)
        $This.iY = Int($iIndex / $aArgs[2])
        $This.iX = $iIndex - ($this.iY * $aArgs[2])
        $this.iX = $aArgs[0] + ($aArgs[4] + $aArgs[6]) * $this.iX
        $this.iY = $aArgs[1] + ($aArgs[5] + $aArgs[7]) * $this.iY

        $This.iHandle = GUICtrlCreateLabel("", $This.iX, $This.iY, $aArgs[4], $aArgs[5], 0x01) ; 0x01 = $SS_CENTER
        GUICtrlSetBkColor($This.iHandle, $This.SetBkColor(Random(0, 16777215, 1))) ; <-- (wrong?) attempt to a call method of this class
        GUICtrlSetOnEvent(-1, "Clicked")
        $iIndex += 1
    EndFunc

    Func Move($iStepX, $iStepY)
        $This.iX += $iStepX
        $This.iY += $iStepY
        GUICtrlSetPos($This.iHandle, $This.iX, $This.iY)
    EndFunc

    Func SetBkColor($iColor)
        GUICtrlSetBkColor($This.iHandle, $iColor)
    EndFunc
#EndRegion

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

@Chimp,

1) if the listing is used letting it formatted as is, then it works, while if I Tidy the AutoIt listing, then it doesn't works anymore, arising an AutoIt error.

I don't use Tidy, but I'll test it to make sure it doesn't break. BTW: What was the error? Can you provide a self-contained example? If so, please use the bug tracker over at github.

2) I've tried to use a call to a method of the class from within the constructor of the same class, but it doesn't work. (could be useful if this was allowed...). 

 The runtime supports this, but there is no "nice" way to implement it in OOPE and keep it working with the current AutoIt stable. This feature would require Maps. As soon as Maps are a thing in the stable, this will be available.

I will answer every single PM, and you are free to ask anything anytime.

Link to comment
Share on other sites

It seems that the "OOP Extender" does not like some embellishments to the listing introduced by Tidy,
The "decorations" of the listing that are not welcome are:

1) The comment added by Tidy to the EndFunc statement (within the #Region Class ... #EndRegion area)

Func _Player()
 
EndFunc   ;==>_Player

the ;==>_Player comment causes an arror like the following:

$aPlayers[$n] = __OOPE_InstantiateClass("int64 iX;int64 iY;int64 iHandle", "  

Error: Unterminated string.

2) the comment added by Tidy to the #EndRegion directive

#Region Class Player

#EndRegion Class Player

the Class Player part added by Tidy to the #EndRegion directive causes the following error on program exit:

Class Player
^ ERROR

Error: Unknown function name.

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

  • 2 months later...

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
 Share

×
×
  • Create New...