Popular Post minxomat Posted November 8, 2015 Popular Post Share Posted November 8, 2015 (edited) IntroductionSince the introduction of ObjCreateInterface, AutoIt is able to create native, real objects. However, this is quite difficult for non-experienced users. This UDF here enables a "classic" syntax for declaring classes and instantiating objects from them. Before you ask: No, it is not just another preprocessor that's "faking" OOP syntax - this is the real deal. While it assists users with a more familiar syntax, objects are created at runtime.Care has been put into this UDF and it is in the authors interest to fix all bugs remaining and implement features as long as the result works in the Stable release of AutoIt.FeaturesDefine an unlimited number of classes.Create unlimited instances of objects.Create arrays of objects.Mix and match different data types in arrays (one or more elements can be objects).Define custom constructors and destructors.Pass an unlimited number of arguments to the constructor (even to all objects in one array at the same time).Automatic garbage collection.Compatible with Object-enabled AutoIt keywords (With etc.), optional parentheses on parameterless functions.Fully AU3Check enabled.IntelliSense catches class-names for auto-completion.Automatically generates a compilable version of the script.Non-instantated classes get optimzed away.Create C-style macros.DownloadRead the Tutorials - Download - Download (forum mirror)Please use the github issue tracker to report bugs or request features. Please read the tutorial before asking a question. Thanks! Edited November 13, 2015 by minxomat Bilgus, JohnOne, Luigi and 6 others 9 I will answer every single PM, and you are free to ask anything anytime. Link to comment Share on other sites More sharing options...
czyt Posted November 8, 2015 Share Posted November 8, 2015 It is so cool~thx 董小姐,你微笑的时候很美,就像安河桥下,清澈的水... Link to comment Share on other sites More sharing options...
JohnOne Posted November 9, 2015 Share Posted November 9, 2015 ooh, looks interesting. I look forward ti trying it.Thanks. minxomat 1 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 More sharing options...
JohnOne Posted November 9, 2015 Share Posted November 9, 2015 (edited) 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 November 9, 2015 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 More sharing options...
minxomat Posted November 9, 2015 Author Share Posted November 9, 2015 (edited) 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 November 9, 2015 by minxomat JohnOne 1 I will answer every single PM, and you are free to ask anything anytime. Link to comment Share on other sites More sharing options...
TheAppleFreak Posted November 9, 2015 Share Posted November 9, 2015 This definitely has my attention. As much as I like AutoIT, sometimes having objects would just make my life a whole lot simpler...Is there anything that script authors would need to keep in mind when using this library? Any best practices that you recommend? Link to comment Share on other sites More sharing options...
minxomat Posted November 9, 2015 Author Share Posted November 9, 2015 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 More sharing options...
Rnde Posted November 10, 2015 Share Posted November 10, 2015 Interesting..I'll lurk around for any changes. Link to comment Share on other sites More sharing options...
minxomat Posted November 11, 2015 Author Share Posted November 11, 2015 @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 More sharing options...
AdmiralAlkex Posted November 12, 2015 Share Posted November 12, 2015 So... Why would one choose this over AutoItObject? .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
minxomat Posted November 12, 2015 Author Share Posted November 12, 2015 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 More sharing options...
AdmiralAlkex Posted November 12, 2015 Share Posted November 12, 2015 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. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
minxomat Posted November 13, 2015 Author Share Posted November 13, 2015 Released 0.3 StableFixed https://github.com/minxomat/AutoIt-OOP-Extender/issues/2Fixed https://github.com/minxomat/AutoIt-OOP-Extender/issues/3Fixed https://github.com/minxomat/AutoIt-OOP-Extender/issues/4Fixed https://www.autoitscript.com/forum/topic/178542-oop-extender-real-object-oriented-programming-with-autoit/?do=findComment&comment=1281714 ( @Chimp )Fixed https://www.autoitscript.com/forum/topic/178542-oop-extender-v03-stable-real-object-oriented-programming-with-autoit/?do=findComment&comment=1281433 ( @JohnOne )Fixed a bunch of unreported issuesImplemented C-style macrosThis release is not compatible with older releases. Please read all tutorials (updated links are in the first post) to understand the changes and new features . Xandy and Gianni 2 I will answer every single PM, and you are free to ask anything anytime. Link to comment Share on other sites More sharing options...
argumentum Posted November 15, 2015 Share Posted November 15, 2015 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. Link to comment Share on other sites More sharing options...
minxomat Posted November 15, 2015 Author Share Posted November 15, 2015 @argumentum,I pushed a broken include by accident. I changed it a few seconds ago, should be working now. I will answer every single PM, and you are free to ask anything anytime. Link to comment Share on other sites More sharing options...
Gianni Posted November 15, 2015 Share Posted November 15, 2015 ... 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 ....expandcollapse popup; 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 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
minxomat Posted November 15, 2015 Author Share Posted November 15, 2015 @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 More sharing options...
Gianni Posted November 15, 2015 Share Posted November 15, 2015 (edited) 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 ;==>_Playerthe ;==>_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 Playerthe Class Player part added by Tidy to the #EndRegion directive causes the following error on program exit:Class Player^ ERRORError: Unknown function name. Edited November 15, 2015 by Chimp Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
asdf8 Posted February 2, 2016 Share Posted February 2, 2016 minxomat, is it possible to get around the problem that the same method names in different classes will cause errors? Link to comment Share on other sites More sharing options...
minxomat Posted February 2, 2016 Author Share Posted February 2, 2016 @asdf8 Submit a feature request at github. I will answer every single PM, and you are free to ask anything anytime. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now