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

    • ScriptJunky
      By ScriptJunky
      I noticed a lack of a constants file for _WinAPI_GetSystemMetrics() so I made this for anyone who wants to add it to their library. Enjoy!  (file attached below)
      #include-once ; #INDEX# ======================================================================================================================= ; Title .........: WinAPI GetSystemMetrics Constants ; AutoIt Version : 3.3.14.5 ; Language ......: English ; Description ...: Constants for _WinAPI_GetSystemMetrics(). ; Author(s) .....: ScriptJunky ; =============================================================================================================================== ; #CONSTANTS# =================================================================================================================== ; _WinAPI_GetSystemMetrics() Global Const $ARRANGE = 56 Global Const $CLEANBOOT = 67 Global Const $CMONITORS = 80 Global Const $CMOUSEBUTTONS = 43 Global Const $CONVERTIBLESLATEMODE = 0x2003 Global Const $CXBORDER = 5 Global Const $CXCURSOR = 13 Global Const $CXDLGFRAME = 7 Global Const $CXDOUBLECLK = 36 Global Const $CXDRAG = 68 Global Const $CXEDGE = 45 Global Const $CXFIXEDFRAME = 7 Global Const $CXFOCUSBORDER = 83 Global Const $CXFRAME = 32 Global Const $CXFULLSCREEN = 16 Global Const $CXHSCROLL = 21 Global Const $CXHTHUMB = 10 Global Const $CXICON = 11 Global Const $CXICONSPACING = 38 Global Const $CXMAXIMIZED = 61 Global Const $CXMAXTRACK = 59 Global Const $CXMENUCHECK = 71 Global Const $CXMENUSIZE = 54 Global Const $CXMIN = 28 Global Const $CXMINIMIZED = 57 Global Const $CXMINSPACING = 47 Global Const $CXMINTRACK = 34 Global Const $CXPADDEDBORDER = 92 Global Const $CXSCREEN = 0 Global Const $CXSIZE = 30 Global Const $CXSIZEFRAME = 32 Global Const $CXSMICON = 49 Global Const $CXSMSIZE = 52 Global Const $CXVIRTUALSCREEN = 78 Global Const $CXVSCROLL = 2 Global Const $CYBORDER = 6 Global Const $CYCAPTION = 4 Global Const $CYCURSOR = 14 Global Const $CYDLGFRAME = 8 Global Const $CYDOUBLECLK = 37 Global Const $CYDRAG = 69 Global Const $CYEDGE = 46 Global Const $CYFIXEDFRAME = 8 Global Const $CYFOCUSBORDER = 84 Global Const $CYFRAME = 33 Global Const $CYFULLSCREEN = 17 Global Const $CYHSCROLL = 3 Global Const $CYICON = 12 Global Const $CYICONSPACING = 39 Global Const $CYKANJIWINDOW = 18 Global Const $CYMAXIMIZED = 62 Global Const $CYMAXTRACK = 60 Global Const $CYMENU = 15 Global Const $CYMENUCHECK = 72 Global Const $CYMENUSIZE = 55 Global Const $CYMIN = 29 Global Const $CYMINIMIZED = 58 Global Const $CYMINSPACING = 48 Global Const $CYMINTRACK = 35 Global Const $CYSCREEN = 1 Global Const $CYSIZE = 31 Global Const $CYSIZEFRAME = 33 Global Const $CYSMCAPTION = 51 Global Const $CYSMICON = 50 Global Const $CYSMSIZE = 53 Global Const $CYVIRTUALSCREEN = 79 Global Const $CYVSCROLL = 20 Global Const $CYVTHUMB = 9 Global Const $DBCSENABLED = 42 Global Const $DEBUG = 22 Global Const $DIGITIZER = 94 Global Const $IMMENABLED = 82 Global Const $MAXIMUMTOUCHES = 95 Global Const $MEDIACENTER = 87 Global Const $MENUDROPALIGNMENT = 40 Global Const $MIDEASTENABLED = 74 Global Const $MOUSEPRESENT = 19 Global Const $MOUSEHORIZONTALWHEELPRESENT = 91 Global Const $MOUSEWHEELPRESENT = 75 Global Const $NETWORK = 63 Global Const $PENWINDOWS = 41 Global Const $REMOTECONTROL = 0x2001 Global Const $REMOTESESSION = 0x1000 Global Const $SAMEDISPLAYFORMAT = 81 Global Const $SECURE = 44 Global Const $SERVERR = 289 Global Const $SHOWSOUNDS = 70 Global Const $SHUTTINGDOWN = 0x2000 Global Const $SLOWMACHINE = 73 Global Const $STARTER = 88 Global Const $SWAPBUTTON = 23 Global Const $TABLETPC = 86 Global Const $XVIRTUALSCREEN = 76 Global Const $YVIRTUALSCREEN = 77  
      WinAPISystemMetricsConstants.au3
    • rcmaehl
      By rcmaehl
      A UDF with Extended Functions for Window Management
       
      Notes:
      Fixes WinGetClassList's barbaric returning of a @LF separated string instead of an array.
       
      Potential Uses:
      Automating applications that change their controls' handles/classes on each launch (e.g. half of Cisco's programs)
       
      Functions:
      _WinGetClassList
      _WinGetClassNNList
      _WindowGetHandleList
      _WindowGetHandleListFromPos
       
      Download: 
      WindowEx.zip  (v0.4)
       
      Changelog:
      10/04/2016 (v0.4): _WinGetClassNNList Fixed : Not Returning an Index when using $2D_ARRAY _WinGetClassNNList Fixed : Not Properly returning $aArray[x][1] on Classes with instances > 9 when using $2D_ARRAY 10/03/2016 (v0.3): _WinGetClassList Added : Exactly the same as WinGetClassList but returns a more civilized Array _WinGetClassNNList Added : Returns Classes and their instances in either a 1D or 2D array depending on Flags _WindowGetHandleList Renamed: _WinGetHandleList SCRIPT BREAKING! _WindowGetHandleListFromPos Renamed: _WinGetHandleListFromPos SCRIPT BREAKING! 10/01/2016 (v0.2): WindowsExConstants.au3 Added : Flags in _WindowGetHandleListFromPos _WindowGetHandleListFromPos Removed: ConsoleWrite left in during debug _WindowGetHandleListFromPos Added : Flag for if part of a Control is at $X, $Y return it as well. 10/01/2016 (v0.1): _WindowGetHandleList Added : Retrieves the handles of classes from a window. _WindowGetHandleListFromPos Added : Retrieves the handles of classes at a specific position from a window. Known and Reported Bugs:
      None reported To Do:
      To Be Decided. Opinions welcome! Upcoming Changes:
      To Be Decided.
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good morning everyone

      I was playing a little bit with "Screen Capture" UDF, and I was trying to make a "Window" capture, but, since I made a GUI which through I fire the event "Capture", my GUI is captured as well, and I don't want to
      This is the line of code that makes the capture:
       
      _ScreenCapture_CaptureWnd($strScreenCaptureFileName, $objActiveWindow, 0, 0, -1, -1, False) And these are the lines of code which select the "active" window:
       
      Local $objCurrentWindow = 9999 If _IsPressed("01") Then $objCurrentWindow = WinGetHandle("[ACTIVE]") If $objCurrentWindow <> $objMyGUI Then $objActiveWindow = $objCurrentWindow EndIf EndIf Sorry If I made stupid mistakes
      Thanks in advance.

      Francesco
    • kcvinu
      By kcvinu
      Hi all,
      I am playing with _GUICtrlButton_Create function. How can i change this button's (or the entire form's) font ?. The in-built GUICtrlSetFont function is not working even when i convert the control handle to control ID with _WinAPI_GetDlgCtrlID ( ) function.  Do i need to use CreateFont api finction and send WM_SETFONT message ? Or is there any other easy and safe ways to do this ?. Thanks in advance.
      Note : This window is created by CreateWindowEx function, not by GUICreate function. 
    • okolaris
      By okolaris
      Hey everyone,
      I thought I might share my little Language UDF plus the more powerful SciTE Tool to ship Strings from SciTE into the xml file. While I haven't had the time to fully adapt the small UDF to one of the big XML-UDFs the so called "Language Transmitter" that basically writes the XML file for you runs mostly on "XML DOM wrapper (COM)" by eltorro. The Transmitter should work with other XML-Language-UDFs depending on their encoding.
       
      First let's start with the UDF, there are two functions of interest: _LangInit($sFilePath) and s($sString) As you will have guessed, _LangInit($sFilePath) is called once to initialize the UDF and s($sString) is used to receive the string to your key. Plain and simple.
      Now to the actual "new" part, the Language Transmitter. It basically allows you to transfer a selected String from SciTE into a xml file. While doing so it will scan for AutoIt variables, macros etc. and parse the string to fit StringFormat(). It then saves the formatted string in the xml file and returns the formatted call into SciTE. If the selected string is already defined it will directly parse the key into SciTE. To change the default output file, you can either edit the ini-file in the @ScriptDir of the LanguageTransmitter.exe or press Alt+A on empty space again and keep clicking cancel/no until the Transmitter let's you select the current output file. Standard output is strings.xml in the current opened AutoIt Script.
      Example:
      ; given the line: MsgBox(16, 'Error', 'Error message') ; select 'Error' run the Transmitter follow the instructions, repeat with 'Error message'. Outcome (e.g.): MsgBox(16, s('Error'), s('Error_msg')) ; Variables and Macro example: $sString = "Value: " & $iValue & @CRLF & 'Another value: '& $iValue2 ; Select the full string including all AutoIt variables and macros etc. in SciTE and press Alt+A (default) to run the LanguageTransmitter ; follow the instructions and it will then paste a formatted string like that into SciTE: $sVar = StringFormat(s('Key'), $iValue, $iValue2) ; the correlating xml entry should look like that: ; <string name="Key">Value: %s\r\nAnother value: %s</string> ; as you can see @CRLF has been replaced with \r\n as well. If you are working on a project and want to directly add a string to the xml file just start the Language Transmitter without selecting any text, enter your string and a key.
      SetUp/Installation
      Examples
      Since xml files are required all examples can be found in the zip file. There are two examples, one includes a language selection interface.
      Language File Checker
      I added a script to check whether the xml file contains all required strings or even unnecessary strings.
       
      Hope you like my little helper!
       
      UDF - LanguageSupport.zip
×