Jump to content
minxomat

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

Recommended Posts

czyt

It is so cool~thx

 


董小姐,你微笑的时候很美,就像安河桥下,清澈的水...

Share this post


Link to post
Share on other sites
JohnOne

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.

Share this post


Link to post
Share on other sites
minxomat

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
  • Like 1

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

Share this post


Link to post
Share on other sites
TheAppleFreak

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?

Share this post


Link to post
Share on other sites
minxomat

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.

Share this post


Link to post
Share on other sites
Rnde

Interesting..I'll lurk around for any changes.

Share this post


Link to post
Share on other sites
minxomat

@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.

Share this post


Link to post
Share on other sites
minxomat

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.

Share this post


Link to post
Share on other sites
AdmiralAlkex

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.

Share this post


Link to post
Share on other sites
minxomat
  • Like 2

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

Share this post


Link to post
Share on other sites
argumentum

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

Share this post


Link to post
Share on other sites
minxomat

@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.

Share this post


Link to post
Share on other sites
Chimp

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

 


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

Share this post


Link to post
Share on other sites
minxomat

@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.

Share this post


Link to post
Share on other sites
Chimp

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

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

Share this post


Link to post
Share on other sites
asdf8

minxomat, is it possible to get around the problem that the same method names in different classes will cause errors?

687474703a2f2f6e34372e696d6775702e6e6574

Share this post


Link to post
Share on other sites
minxomat

@asdf8 Submit a feature request at github.


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

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

  • Similar Content

    • Tersion
      By Tersion
      Here the this wiki page with list of available UDFs for data compression. For my tasks I only need ZIP support, so I started looking at pure AutoIt UDFs without any 3rd party dlls. And found out that most of available realizations uses standard ("native method") Windows dll - "zipfldr.dll". So for now I chose ZIP UDF by wraithdu. I've tested it on Windows 7 (x64) and it seem works fine. But here the comment from another topic where user says that Windows 10 discontinued support of "zipfldr.dll". Now I confused. I don't have around any Windows 10 machine to tested it. So maybe someone could confirm or deny that? Or maybe would better to switch to UDF with 7zip dll?
      I need an advice...
    • TheSaint
      By TheSaint
      Here is the bare bones of a UDF I have started work on.
      Mostly just a proof of concept at this stage, and still need to add some functions and dress the UDF up a bit ... to look like a UDF ... though it has my own distinct styling, especially as I have never really developed a UDF before now .... used plenty and modified plenty though. I've even invented my own UDF variable naming convention, which I am sure some of you will be aghast at. I work with what feels best for me, but others are free to adapt if they wish.
      The idea is to emulate the simplicity of INI files, but gain the benefits of SQL.
      Two scripts are provided.
      (1) The UDF, a work in progress - SimpleSQL_UDF.au3
      (2) An example or testing script - UDF_Test.au3
      Another first for me, is creating a 2D array from scratch, never done that before, that I can recall ... never had a need, and even for 1 dimension arrays, for a long time now, I have just used _StringSplit to create them. So I needed a bit of a refresher course, which my good buddy @TheDcoder assisted me with ... not without some angst I might add. LOL
      SimpleSQL_UDF.zip  (12 downloads previously)
      (I have now completed all the functions I intended to. My next update will be a big improvement, bringing things more inline with my latest INItoSQL DB program changes.)
      Program requires the sqlite3.dll, not included, but easily enough obtained.
      Hopefully the usage is self-evident ... just change the Job number variable in the UDF_Test.au3 file to check the existing functions out.
      Enjoy!
      P.S. This is also related to a new program I have just finished and uploaded - INItoSQL DB
    • xtcislove
      By xtcislove
      Hello,
      as a start in Autoit i tried something i was missing since im using Autoit. 

      I build a custom MessageBox which has a large amount of custom options and which scales its size on the parameters you set. 

      Aviable Settings:
      -Title
      -Unlimited Buttons
      -Text Color (Buttons, Text)

      -Background Color (Msgbox, Buttons, Label) 

      -Button Timeout
      -Autoclose Timeout
      -Icon (Default, No Icon, Custom)

      -Label/ Button Style. 
      -Transparency

      I tried to keep this as close as i could to a Msgbox i was used too on my batch times.

      After i was ready i realised, @Melba23 probably build a way better msgbox which would have suit my needs enterly, anyway thanks to @Melba23 because i use his Stringsize UDF. 

       
       
      local $Message = _sMsgBox("Test", 6, "Continue?") if @extended <> -1 Then MsgBox(0, @extended, $Message&" Button pressed")  
      ScalingMessageBox.au3
    • Gowrisankar
      By Gowrisankar
      Dear members, 
      I am working on a project where, emails from outlook are to be read and moved to various folders within the mailbox, based on the content of the emails.
      I used the below code for moving mails. It works fine when I run it against individual mail ids. But when I run it on Shared mailbox, the mails are not moved to respective folders.
      _OL_ItemMove($oOutlook, $sEntryId, Default, $sDestinationFolder) The value of $sEntryId is saved in an excel report initially. The current process reads the $sEntryId from the excel and passes it to "_OL_ItemMove" statement.
      Requesting the guidance of the forum members in this issue.
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good evening everyone
      I am working with Word UDF ( thanks @water! ), and, especially, with the function _Word_DocFindReplace().
      The replace does work everywhere in the document, but, it does not work in Headers or Footers.
      Am I missing something or am I forced to use the code below?
      I have already looked in the Help file ( about _Word_DocFindReplace() ), but there are no mentions about replace text in Headers/Footers.
      Sub FindAndReplaceFirstStoryOfEachType() Dim rngStory As Range For Each rngStory In ActiveDocument.StoryRanges With rngStory.Find .Text = "find text" .Replacement.Text = "I'm found .Wrap = wdFindContinue .Execute Replace:=wdReplaceAll End With Next rngStory End Sub Thanks everyone in advance


      Best Regards.
×