Jump to content

Search the Community

Showing results for tags 'OOP'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 5 results

  1. - _____ _____ _ _ - |_ _|___ ___ ___ _ _| __|___ ___|_|___| |_ - | | | -_| -_| | | |__ | _| _| | . | _| - |_| |___|___|_|_|_ |_____|___|_| |_| _|_| - By TarreTarreTarre|___|Build '1.0.0' |_| + F5 = Run script + F6 = Build 'AU3' + F7 = Build 'EXE' + F8 = Options GUI + F10 = Exit TeenyScript All example code and documentation moved to: http://teenyscript.tarre.nu/documentation Official Github repo: http://github.com/tarreislam/teenyscript F.A.Q Q: What is TeenyScript? A: TeenyScript is a Superset of AutoIt which makes it more advanced Q: How does it work? A: TeenyScript code are parsed into native AutoiT code Q: Does it depend on anything else than AutoIt? A: Just one dependency, that is AutoitObject, the best UDF ever created for AutoIt, besides that, only Native AutoIt is used Features "Anonymous" functions Endless scope nesting OOP (powered by AutoitObject) User-friendly integration Powerful macros Namespaces Lists Project support, for easy deployment Userfriendly GUI for userfriendly Tasks for the Userfriendly person And much more To come You decide, I am happy to do requests! Install and Update TeenyScript HOW TO GET STARTED Run TeenyScript.au3 Now this should see something like this in your console Code Press F8 and navigate to the misc tab to install SciTE calltips Run \ Build \ Compile How to run with Sublime Text Here is some examples of TeenyScript code ;Basic List usage $Example_A = Func() ; Create a list Local $myList = { 'Name': 'Tarre' } ; Add \ Change data on $MyList $myList{'Age'} = 25 ; Create MySecondList Local $MySecondList = { "Name" => "John", "Age" => "00" } ; Using variable instead of a string Local $KeyName = "Age" Local $KeyVal = 1337 $MySecondList{$KeyName} = $KeyVal ; You may also pass lists to lists. however this has to be done in this fashion. Local $oList = {'myList': $myList, 'mySecondList' => $MySecondList} ; Return the objects Return $oList EndFunc();call the function on the variable ; Loop through list and print their values $Example_B = Func() Local $MyList = {'A': 'Hello FROM A', 'B': 'Hello FROM B', 'C': 'Hello FROM C'} Local $aNames = ['A', 'B', 'C'] For $i = 0 To UBound($aNames) -1 MsgBox(0,0,$myList{$aNames[$i]}) Next EndFunc #MAIN MsgBox(0,"Example A 1", $Example_A.myList.Name) MsgBox(0,"Example A 2", $Example_A.myList.Age) MsgBox(0,"Example A 3", $Example_A.mySecondList.Name) MsgBox(0,"Example A 4", $Example_A.mySecondList.Age) $Example_B(); Execute examble B Here is a non class nested function calculator example (calculator.ts.au3) $calculator = Func($a, $and, $b) $division = Func($a, $b) if Not $a or Not $b Then Return "Error dividing 0" EndIf Return $a/$b EndFunc Switch $and Case '+' Return $a + $b Case '-' Return $a - $b Case '/' Return $division($a, $b) Case '*' Return $a * $b EndSwitch Return "Unkown attribute "&$and EndFunc #MAIN ConsoleWrite($calculator(25, '*', 25)&@CRLF) ConsoleWrite($calculator(25, '/', 0) & @CRLF) ConsoleWrite($calculator(1, '^', 2) & @CRLF) teeny-script.zip (OLD) TeenyScript beta2.zip (OLD) teeny-script Beta 4.zip (OLD) teeny-script Beta 5.zip (OLD) teeny-script BETA 6.zip (OLD) TeenyScript Beta 7.zip (OLD) teeny-script Beta 8.zip (OLD) TeenyScript-master 1.0.0.zip (OLD) TeenyScript-1.1.0.zip (OLD) TeenyScript-1.2.0.zip (OLD) TeenyScript-2.0.0.zip (OLRD, Release notes) TeenyScript-2.1.3.zip (Newest 2016-09-16, Release notes)
  2. Introduction Since 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. Features Define 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.Download Read 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!
  3. I posted this the other day, but thought I would post in a separate topic instead. #include <MsgBoxConstants.au3> ; ---- Start of Person Class ; Stored in the 'object' to verify it's our 'object' and not some random array Global Const $PERSON_GUID = '4197B285-6AB1-489B-8585-08C852E33F3D' ; Friendly names for 0, 1, 2 and 3 Global Enum $PERSON_AGE, $PERSON_NAME, $PERSON_ID, $PERSON_MAX ; Constructor Func Person($sName, $iAge) Local $hPerson[$PERSON_MAX] ; Set the GUID, so as the verification will work $hPerson[$PERSON_ID] = $PERSON_GUID Person_SetAge($hPerson, $iAge) Person_SetName($hPerson, $sName) ; Return the Person 'object' Return $hPerson EndFunc ;==>Person ; Getter for the age property Func Person_GetAge(ByRef $hPerson) Return _Person_IsObject($hPerson) ? $hPerson[$PERSON_AGE] : Null EndFunc ;==>Person_GetAge ; Setter for the age property Func Person_SetAge(ByRef $hPerson, $iAge) ; If not a valid 'object' or integer then return If Not _Person_IsObject($hPerson) Or Not IsInt($iAge) Then Return ; Set the age $hPerson[$PERSON_AGE] = $iAge EndFunc ;==>Person_SetAge ; Getter for the name property Func Person_GetName(ByRef $hPerson) Return _Person_IsObject($hPerson) ? $hPerson[$PERSON_NAME] : Null EndFunc ;==>Person_GetName ; Setter for the name property Func Person_SetName(ByRef $hPerson, $sName) ; If not a valid 'object' then return If Not _Person_IsObject($hPerson) Then Return ; Set the name $hPerson[$PERSON_NAME] = $sName EndFunc ;==>Person_SetName ; ToString() for the 'object' Func Person_ToString(ByRef $hPerson) Return _Person_IsObject($hPerson) ? StringFormat('Name: %s, Age: %i', $hPerson[$PERSON_NAME], $hPerson[$PERSON_AGE]) : Null EndFunc ;==>Person_ToString ; Check if it's a valid 'object' and not some random array. "NTERNAL ONLY! Func _Person_IsObject(ByRef $hPerson) Return UBound($hPerson) = $PERSON_MAX And $hPerson[$PERSON_ID] == $PERSON_GUID EndFunc ;==>_Person_IsObject ; ---- End of Person Class Example() Func Example() ; Store the Person 'object', which is just a glorified array Local $hP1 = Person('John', 30) ; Display the 'object' MsgBox($MB_SYSTEMMODAL, 'Person 1', Person_ToString($hP1)) ; Create a new person ; Store the Person 'object', which is just a glorified array Local $hP2 = Person('James', 36) ; Display the 'object' MsgBox($MB_SYSTEMMODAL, 'Person 2', Person_ToString($hP2)) ; Set the age for Person 2 Person_SetAge($hP2, 45) ; Display the 'object' MsgBox($MB_SYSTEMMODAL, 'Person 2 - Revised', Person_ToString($hP2)) EndFunc ;==>Example
  4. Hi everybody! Here is my new super tool! It's an AutoItObject TCP Class! Very simple to use, with example and complet decumentation (Made with NaturalDocs) There are two classes: Client, and Server. - The data are encrypted! - The server can handle multiple clients - Data buffering, if you send a big amount of data, it will received as it was sent, not as many little parts of it - OOP programing! (very simple!) PS: You don't need to download AutoItObject, everything you need is in the zip. Update: 03/11/2011 +: Added, -: Deleted/Deprecated, *: Modified, !: Bug corrected === 1.1c === (30/10/2011) Server: +: ClientGetBufferLen method +: Completed doc of ClientPropertyGet and ClientPropertySet methods (Return values) *: Now, when calling .Shutdown, the Callback_LostClient is called for each client. !: Corrected bug: Script error when calling .DisconnectAll befor calling at least one time .Startup (Main socket array was not dimensioned)UDF_TCPClass.rar
  5. I've been thinking about this for the last couple of weeks, and I've finally got around to putting together a proof of concept. As far as OOP goes, Javascript is a pretty damn good language -- very flexible, but lets look at some code. Here is a two button form for AutoIt written in Javascript. var $=this; var hgui; this.MsgHandler_=function (m){ if (m==$.AutoIt.GUI_EVENT_CLOSE) { $.AutoIt.GUIDelete(hgui); return true; }else if (m==button1) { $.AutoIt.Run("notepad.exe"); }else if (m==button2) { alert('Thanks from a javascript alert box!'); } return false; } var button1,button2; function Example1(){ var msg; hgui=$.AutoIt.GUICreate("My Gui",400,500); button1=$.AutoIt.GUICreateButton("Run Notepad",10,10,200,30); button2=$.AutoIt.GUICreateButton("Press Me",10,40,200,30); $.AutoIt.GUISetState($.AutoIt.SW_SHOW,hgui); } Example1(); This code would reside in an external file and be called by AutoIt. I've created a framework in AutoIt using AutoItObject that is just big enough to make this code work. Basically I am creating an AutoItObject, tacking on some core AutoIt functions and constants, and sending it off to play in Javascript land. There is much more to be tacked on. Other than this AutoItObject being a proxy for AutoIt functionality, there is a Javascript COM object into which the javascript file is loaded, and a message loop that calls back into the javascript. The framework is 300 lines of code. Before I extend this, I want to know if AutoIt ALREADY has a COM object I that I can use like this. But I am thinking that even if it does, this hand-coded way would be better because you can make the calls pass objects instead of parameters. Here is the framework: #include <AutoItObject.au3> #include <GUIConstants.au3> Global $thisfile=@ScriptFullPath; Global $logg=$thisfile&".log.txt"; Global $jsfile=$thisfile&".js"; ;e C:\batch\borg\TestJsaio.au3.js ;fret not, you do not need, will be a no-op if not exist Global Const $snarl="C:\batch\Snarl_CMD.exe"; ; need script exit for AIO shutdown OnAutoItExitRegister("EvtScriptExit") _AutoItObject_StartUp() ; error handler Global $oError $oError = ObjEvent("AutoIt.Error", "_ErrFunc") ; JScript Com globals Global $_ComObj_proxy Global $_com Global $_Js JScriptInit() ;;;;;;;;;;;;;;;;;;;;;;;;;;done inits ;;;;;;;;;;; begin framework ; set up a mini framework of AutoIt Functions/constants and stick them on an object Global $AutoItForCom=_AutoItObject_Create(); ;_AutoItObject_AddMethod(ByRef $oObject, $sName, $sAutoItFunc, $fPrivate = False) _AutoItObject_AddMethod($AutoItForCom,"GUICreate","GUICreate_AI") _AutoItObject_AddMethod($AutoItForCom,"GUISetState","GUISetState_AI") _AutoItObject_AddMethod($AutoItForCom,"GUIGetMsg","GUIGetMsg_AI") _AutoItObject_AddMethod($AutoItForCom,"GUIDelete","GUIDelete_AI") _AutoItObject_AddMethod($AutoItForCom,"MsgBox","MsgBox_AI") _AutoItObject_AddMethod($AutoItForCom,"GuiCreateButton","GuiCreateButton_AI") _AutoItObject_AddMethod($AutoItForCom,"Run","Run_AI") ;_AutoItObject_AddProperty(ByRef $oObject, $sName, $iFlags = $ELSCOPE_PUBLIC, $vData = "") _AutoItObject_AddProperty($AutoItForCom, "SW_SHOW", $ELSCOPE_PUBLIC+$ELSCOPE_READONLY, @SW_SHOW) _AutoItObject_AddProperty($AutoItForCom, "GUI_EVENT_CLOSE", $ELSCOPE_PUBLIC+$ELSCOPE_READONLY, $GUI_EVENT_CLOSE) ;;; here are the tie-ins that the object will call Func GUICreate_AI($me,$title,$width,$height) #forceref $me ;GUICreate ( "title" [, width [, height [, left [, top [, style [, exStyle [, parent]]]]]]] ) Local $rv=GUICreate($title,$width,$height) Return $rv EndFunc Func GUISetState_AI($me,$flag,$hwnd) #forceref $me ;GUISetState ( [flag [, winhandle]] ) Local $rv=GUISetState($flag,HWnd($hwnd));need to covert Int32 Return $rv EndFunc Func GUIGetMsg_AI($me,$advanced) #forceref $me Local $rv= GUIGetMsg ($advanced) Return $rv EndFunc Func GUIDelete_AI($me,$winhandle) #forceref $me Local $rv=GUIDelete($winhandle) Return $rv EndFunc Func MsgBox_AI($me,$flag,$title,$text) #forceref $me ;MsgBox ( flag, "title", "text" [, timeout [, hwnd]] ) Local $rv=MsgBox($flag,$title,$text) Return $rv EndFunc Func GUICreateButton_AI($me,$text,$left,$top,$width=Default,$height=Default,$style=Default,$exstyle=Default) #forceref $me ;GUICtrlCreateButton ( "text", left, top [, width [, height [, style [, exStyle]]]] ) Local $rv=GUICtrlCreateButton ( $text, $left, $top, $width, $height, $style, $exstyle) Return $rv EndFunc Func Run_AI($me,$program,$wkdir=Default,$show_flag=Default,$opt_flag=Default) #forceref $me ;Msg2("run",$program) Local $rv; If False Then ElseIf @NumParams==2 Then $rv=Run($program) ElseIf @NumParams==3 Then $rv=Run($program,$wkdir) ElseIf @NumParams==4 Then $rv=Run($program,$wkdir,$show_flag) ElseIf @NumParams==5 Then $rv=Run($program,$wkdir,$show_flag,$opt_flag) EndIf ;Run ( "program" [, "workingdir" [, show_flag [, opt_flag]]] ) ;Local $rv=Run($program,$wkdir,$show_flag,$opt_flag) Return $rv EndFunc ;;;;;;;;;;;;;;;; end of tie-ins ;;;;;;;;;; setup JScript COM obj Global $jso=NewComObj() ; import our AutoIt Proxy into the jso $jso.set("AutoIt", $AutoItForCom) ; read our javascript file Global $ftext=FileRead($jsfile) ; set the file text up as a Main function $jso.set_function("Main", "", $ftext) ; need to run our message loop in autoit code, but pass it back to JS land here $jso.set_function("MsgHandler", "m", "return eval('this.MsgHandler_(m)');") ; hold on to your britches... ; this call will run through the js file and the file must do a setup and have a callback MsgHandler_ $jso.Main() ;; Message Loop Local $end_if_true Local $m While True $m=GUIGetMsg(0) $end_if_true=$jso.MsgHandler($m) ;Msg($end_if_true); If $end_if_true Then ExitLoop EndIf WEnd Exit ;; the only thing worth looking at below this point is the _ComObj_init and friends ;;;;;;;;;;;;;;;functions Func EvtScriptExit() ;Msg("EvtScriptExit") _AutoItObject_Shutdown() ;_logline('EvtScriptExit') ;If IsObj($MidiMgr) Then ; $MidiMgr.Terminate() ;EndIf EndFunc Func Msg($s) MsgBox(0,$thisfile,$s) EndFunc Func Msg2($t,$s) MsgBox(0,$t,$s) EndFunc Func logclear() FileDelete($logg) EndFunc Func _logline($line) logline($line) EndFunc Func logline($line) Local $fh1=FileOpen($logg,1); If $fh1<>-1 Then FileWriteLine($fh1,$line) FileClose($fh1) EndIf EndFunc Func logsnarl($line) logerr($line) snarl(10,'Fatal Error',$line) EndFunc Func snarl($i,$t,$s) If Not FileExists($snarl) Then Return EndIf $s1=StringReplace($s,'"',"'") $t1=StringReplace($t,'"',"'") $cmd=$snarl&' snShowMessage '&$i&' "'&$t1&'" "'&$s1&'"'; Run($cmd) EndFunc ;;;;js utils ; #FUNCTION# ================================================================== ; Name : _ComObj_init ; Description : Creates MS Windows Script control and deploy it as proxy for ; AutoIt COM object binding. ; Syntax : _ComObj_init([$VBScriptSupport = false]) ; Parameter : $VBScriptSupport ; By default JScript doesn't have alert() function, it is provided ; by browser's window object. ; We can emulate this using VBScript's MsgBox function, which is ; performance hog because we need another ScriptControl instance. ; Other advantage is to be able to execute other VBScript's methods ; within function via vb.Eval() method. ; This feature is disabled by default. ; ============================================================================= Func _ComObj_init ($VBScriptSupport = false) Local $_Script $_Script = ObjCreate("ScriptControl") $_Script.Language = "JScript" $_Script.Timeout = 60000 ;$_Script.AddCode("var $=this,arrays=[],vb;function set_vbscript($) {vb=$;vb.Language='VBScript';vb.AllowUI=true;}function alert(s){if(vb)vb.Eval('MsgBox(Unescape(""'+s+'""), 0, ""Autoit"")')}function get_proxy(){return $}function new_object($){$=new Function('return{'+$+'}')();$.set=function(k, v){$[k]=v};$.unset=function(k){delete $[k]};$.set_object=function(k,$){this.set(k,new_object($))};$.set_array=function(){var v=[];for(var i=0;i<arguments.length;i++)v[i]=arguments[i];$.set(v.shift(),new_array.apply(this,v))};$.set_function=function(k,p,$){this.set(k,new_function(p,$))};return $}function new_array(){var v=[];for(var i=0;i<arguments.length;i++)v[i]=arguments[i];return v}function array_get($,k){return $[k]}function array_set($,k,v){return $[k]=v}var new_function=(function(){function F(r) {return Function.apply(this,r)}F.prototype = Function.prototype;return function(p,$){p=p.split(/\s*,\s*/);p.push($);return new F(p)}})()") ;a[a.length]=i; ;function new_array(){var v=[];for(var i=0;i<arguments.length;i++)v[i]=arguments[i];return v} Local $more= _ "$.get=function(k){return $[k]};" & _ "$.has=function(n){" & _ " for (var i in this){" & _ " if (i!=n){" & _ " continue;" & _ " }" & _ " if (!this.hasOwnProperty(i)){" & _ " continue;" & _ " }" & _ " if (typeof(this[i])=='function'){" & _ " continue;" & _ " }" & _ " return true;" & _ " };" & _ " return false;" & _ "};" & _ "$.keys=function(){" & _ " var a=[];" & _ " for (var i in this){" & _ " if (this.hasOwnProperty(i)){" & _ " if (typeof(this[i])!='function'){" & _ " a[a.length]=i;" & _ " }" & _ " }" & _ " };" & _ " return a;" & _ "};" & _ "$.set2=function(){" & _ " for(var x=0;x<arguments.length-1;x+=2){" & _ " this[arguments[x]]=arguments[x+1]" & _ " }" & _ "};" & _ "Array.prototype.item=function(n){" & _ " return this[n];" & _ "};" & _ "Array.prototype.has=function(v){" & _ " for(x=0;x<this.length;x++){" & _ " if(this[x]==v){return true;}" & _ " }" & _ " return false;" & _ "};" & _ "Array.prototype.asString=function(d){" & _ " var s='';" & _ " for(x=0;x<this.length;x++){" & _ " if(s==''){s=this[x];}else{s+=d+this[x];}" & _ " }" & _ " return s;" & _ "};" $_Script.AddCode("var $=this,arrays=[],vb;function set_vbscript($) {vb=$;vb.Language='VBScript';vb.AllowUI=true;}function alert(s){if(vb)vb.Eval('MsgBox(Unescape(""'+s+'""), 0, ""Autoit"")')}function get_proxy(){return $}function new_object($){$=new Function('return{'+$+'}')();$.set=function(k, v){$[k]=v};"&$more&"$.unset=function(k){delete $[k]};$.set_object=function(k,$){this.set(k,new_object($))};$.set_array=function(){var v=[];for(var i=0;i<arguments.length;i++)v[i]=arguments[i];$.set(v.shift(),new_array.apply(this,v))};$.set_function=function(k,p,$){this.set(k,new_function(p,$))};return $}function new_array(){var v=[];for(var i=0;i<arguments.length;i++)v[i]=arguments[i];return v}function array_get($,k){return $[k]}function array_set($,k,v){return $[k]=v}var new_function=(function(){function F(r) {return Function.apply(this,r)}F.prototype = Function.prototype;return function(p,$){p=p.split(/\s*,\s*/);p.push($);return new F(p)}})()") If $VBScriptSupport = true Then $_Script.Run("set_vbscript", ObjCreate("ScriptControl")) Return $_Script EndFunc ; ============================================================================= Func NewComObj() Local $com While True $com=$_com.new_object("") Sleep(30) If IsObj($com) Then ExitLoop EndIf WEnd Sleep(30) Return $com EndFunc Func JScriptInit() $_ComObj_proxy = _ComObj_init(true) $_com = $_ComObj_proxy.Run("get_proxy") $_Js = $_com.new_object("") $_Js.set_function("AIOSetProperty","o,n,v","o[n]=v;") EndFunc Func JS_SetProp() $_Js = $_com.new_object("") $_Js.set_function("AIOSetProperty","o,n,v","o[n]=v;") Return $_Js; EndFunc My main questions are... Why doesn't this already exist, and where is it? and... Why doesn't this already exist -- what wall am I headed for?
×
×
  • Create New...