Busti Posted May 17, 2019 Share Posted May 17, 2019 (edited) Hello, first of all, sorry for the misleading name, this is in no way a "faster working objects" method. This works with the genius work of prod@ndy and the others "AutoItObject.au3". (which is realy sad that there is no more real development behind it / at least as far as i saw - love your work - kudos to you all) I called this faster objects, because - i think mainly cause i can read it better and therefore work faster with it. haha - theres not even close to be everything included which the original udf offers (which still can be used ofc.) - i just added some additions and changed the way to create the objects a little bit. for example: expandcollapse popup#include-once #include "XML_Core.au3" Global $oXML ;Object var to use in the main script - global initialiser _CreateXMLObject() Func _CreateXMLObject() ; create XML Class Local $XML_Object_Creation = _ShortObjectCreater("[XML Object]", "Send POST/GET Requests or Translate Text."&@CRLF&"Call .__showdetails('methodname/property') for more informations.") ; main functions $XML_Object_Creation.create () $XML_Object_Creation.method ("start", "_XML_Startup", "Start the XML Object" & @CRLF & "Usage: $object.start()" ) $XML_Object_Creation.method ("post", "_XML_Post" ) $XML_Object_Creation.method ("get", "_XML_Get" ) $XML_Object_Creation.method ("action", "_XML_Action" ) $XML_Object_Creation.method ("_send", "_XML_SendWithAgent" ) $XML_Object_Creation.method ("response", "_XML_ResponseText" ) $XML_Object_Creation.method ("agent", "_XML_Agent" ) $XML_Object_Creation.method ("close", "_XML_Close" ) $XML_Object_Creation.method ("setResponse", "_XML_SetResponseText" ) $XML_Object_Creation.method ("getResponse", "_XML_GetResponseText" ) $XML_Object_Creation.method ("setURL", "_XML_SetURL" ) $XML_Object_Creation.method ("getURL", "_XML_GetURL" ) $XML_Object_Creation.method ("close", "_XML_Close" ) ; translate functions $XML_Object_Creation.method ("gTranslate", "_XML_GoogleTranslateText" ) $XML_Object_Creation.method ("setTranslateResult", "_XML_SetGoogleTranslateResult" ) $XML_Object_Creation.method ("getTranslateResult", "_XML_GetGoogleTranslateResult" ) $XML_Object_Creation.prop ("_translateResult") $XML_Object_Creation.method ("cleanTranslateResult", "__XML_CleanTranslateResult" ) $XML_Object_Creation.method ("_setCleanTranslationResult", "_XML_SetCleanTranslateResult" ) $XML_Object_Creation.method ("_getCleanTranslationResult", "_XML_GetCleanTranslateResult" ) $XML_Object_Creation.prop ("_cleanTranslateResult") $XML_Object_Creation.method ("getLastTranslateURL", "_XML_GetLastTranslateURL" ) ; encoding / decondig $XML_Object_Creation.method ("encodeURI", "_XML_EncodeURI" ) $XML_Object_Creation.method ("setEncode", "_XML_SetEncodeURI" ) $XML_Object_Creation.method ("getEncode", "_XML_GetEncodeURI" ) $XML_Object_Creation.method ("decodeURI", "_XML_DecodeURI" ) $XML_Object_Creation.prop ("_encode") $XML_Object_Creation.prop ("_decode") $XML_Object_Creation.prop ("tUrl") ; coding $XML_Object_Creation.method ("setCookie", "_XML_SetCookie" ) $XML_Object_Creation.method ("getCookie", "_XML_GetCookie" ) $XML_Object_Creation.method ("getSetCookie", "_XML_GetSetCookie" ) $XML_Object_Creation.method ("cLogin", "_XML_LoginWithCookie" ) $XML_Object_Creation.prop ("_cookie") $XML_Object_Creation.prop ("url") $XML_Object_Creation.prop ("_XML_OBJECT") $XML_Object_Creation.prop ("_response") ; create XML Object $oXML = $XML_Object_Creation.save() $XML_Object_Creation = "" ;free up space EndFunc I also used some kind of functionality to add a description to each function at each creation - which then can be shown by the __showdetail command. for example: MsgBox(0, "", $oXML.__Name & @CRLF & $oXML.__Description ) gives you then: or: MsgBox(0, "", $oXML.__showdetails("start")) returns: Everything except the description is auto generated. The description will be added when you are creating the method: You can also look for created propertys, which also get automatically added to the "array": MsgBox(0, "", $oXML.__showdetails("code")) returns: I wanted to also add the posibility to show the value of the propertys - but i did not yet find out - how to evaluate it out of the array - like, without $oXML._encode / cause what you see on the picture is the value out of $s[$i] - just the stored name of the property, but not the address to the value. I also included a fully working example of an google translator: ;translate test: Local $trans $oXML.gTranslate( "hallo ich soll ein englischer text werden" ) $trans = $oXML.getTranslateResult() ConsoleWrite( "!Translate:" & @CRLF & "----------------------------------------" & @CRLF & $trans & @CRLF ) $oXML.close() ;free up memory $oXML.start(); reopen for another test Local $trans $oXML.gTranslate( "ich will auch übersetzt werden" ) $trans = $oXML.getTranslateResult() ConsoleWrite( "!Translate2:" & @CRLF & "----------------------------------------" & @CRLF & $trans & @CRLF ) $oXML.close() ;free up memory As this entire thing is a work in progess and in no way even close to the finish, i'm going to post you the github link, where you could get the entire thing and just use the fasterobjects+xml if you want. I'm going for a big project in my work and i need a good framework which i can easy adapt on different situations, that's why i'm creating this thing. And i freaking love your autoit objects - all other ones i found here, where - earm.. not reliable/ always working.. here is the FastObject.au3 expandcollapse popup#include-once #include "AutoItObject.au3" ; start autoit object _AutoItObject_StartUp() Func _ShortObjectCreater($name="",$desc="") Local $o = _AutoItObject_Create() _AutoItObject_AddMethod ($o, "create", "_create_object") _AutoItObject_AddMethod ($o, "delete", "_delete_object") _AutoItObject_AddMethod ($o, "method", "_add_method") _AutoItObject_AddMethod ($o, "prop", "_add_property") _AutoItObject_AddMethod ($o, "save", "_save_obj" ) _AutoItObject_AddProperty ($o, "Name") _AutoItObject_AddProperty ($o, "Description") _AutoItObject_AddProperty ($o, "__obj") _AutoItObject_AddProperty ($o, "MethodList") _AutoItObject_AddProperty ($o, "MethodDescription") $o.Name = $name $o.Description = $desc $o.MethodList = "" $o.MethodDescription = "" $o.__obj = 0 Return $o EndFunc Func _save_obj($oSelf) Return $oSelf.__obj EndFunc Func _create_object($oSelf) Local $o = _AutoItObject_Create() Dim $emptymethod[1], $emptymethoddesc[1], $emptyproperty[1] _AutoItObject_AddMethod ($o, "__addMADTA", "__AddMethodAndDescriptionToArray") _AutoItObject_AddMethod ($o, "__addPTA", "__AddPropertyToArray") _AutoItObject_AddMethod ($o, "__showdetails", "__ShowDetailsFor") _AutoItObject_AddProperty ($o, "__Name") _AutoItObject_AddProperty ($o, "__Description") _AutoItObject_AddProperty ($o, "__obj") _AutoItObject_AddProperty ($o, "__MethodArray") _AutoItObject_AddProperty ($o, "__MethodDescriptionArray") _AutoItObject_AddProperty ($o, "__PropertyArray") _AutoItObject_AddProperty ($o, "__MethodInternalCounter") _AutoItObject_AddProperty ($o, "__PropertyInternalCounter") $oSelf.__obj = $o $o.__obj = $o $o.__Name = $oSelf.Name $o.__Description = $oSelf.Description $o.__MethodArray = $emptymethod $o.__MethodDescriptionArray = $emptymethoddesc $o.__MethodInternalCounter = 0 $o.__PropertyArray = $emptyproperty $o.__PropertyInternalCounter= 0 EndFunc Func __ShowDetailsFor($oSelf, $name) Local $c, $s, $x, $f=0 $c = $oSelf.__MethodInternalCounter $s = $oSelf.__MethodArray $x = $oSelf.__MethodDescriptionArray For $i = 1 To $c If ($s[$i]=$name) Then Return "[SHOWING DETAILS FOR METHOD]" & @CRLF & $s[$i] & @CRLF & @CRLF & $x[$i] Next $c = "" $s = ""; nothing found, research vars and $x = ""; search propertys $c = $oSelf.__PropertyInternalCounter $s = $oSelf.__PropertyArray For $i = 1 To $c If StringInStr($s[$i],$name) Then If $f = 0 Then $x = "[FOUND PROPERTY]" & @CRLF & @CRLF $x &= $s[$i]&@CRLF ;& " current value: '" & @CRLF; & Execute("$oSelf.$s[$i]") &"'"& @CRLF ; <- i want to show the value of the property - not yet working :/ $f += 1 ; found 1 property - not needed atm any further - but who knows.. EndIf Next If ($f>=1) Then Return $x Return SetError(-1, 0, "Did not found any method or property with the request '"&$name&"'" & @CRLF & "The Method search is casesensitive, the property search is not." ) EndFunc Func __AddMethodAndDescriptionToArray($oSelf, $n, $d) Local $c = $oSelf.__MethodInternalCounter + 1, $methodArray, $methodDescArray $methodArray = $oSelf.__MethodArray $methodDescArray = $oSelf.__MethodDescriptionArray ReDim $methodArray[$c+1], $methodDescArray[$c+1] $methodArray[0] = $c $methodDescArray[0] = $c $methodArray[$c] = $n $methodDescArray[$c] = $d $oSelf.__MethodArray = $methodArray $oSelf.__MethodDescriptionArray = $methodDescArray $oSelf.__MethodInternalCounter += 1 EndFunc Func __AddPropertyToArray($oSelf, $n) Local $c = $oSelf.__PropertyInternalCounter + 1, $methodArray $methodArray = $oSelf.__PropertyArray ReDim $methodArray[$c+1] $methodArray[0] = $c $methodArray[$c] = $n $oSelf.__PropertyArray = $methodArray $oSelf.__PropertyInternalCounter += 1 EndFunc Func _delete_object($oSelf, ByRef $obj_var) Return $obj_var = 0 EndFunc Func _add_method($oSelf, $objmethod, $function_name, $desc="no description yet") Local $obj = $oSelf.__obj _AutoItObject_AddMethod($obj, $objmethod, $function_name) $obj.__addMADTA( $objmethod, "[OBJECT CALL]"&@CRLF&"$createdObject."&$objmethod&@CRLF&@CRLF&"[INTERNAL CALL]"&@CRLF&$function_name&@CRLF&@CRLF&"[DESCRIPTION]"&@CRLF&$desc) EndFunc Func _add_property($oSelf, $prop ) Local $obj = $oSelf.__obj _AutoItObject_AddProperty($obj, $prop ) $obj.__addPTA($prop) EndFunc Func _set_property($oSelf, $prop, $set ) ;Return $obj.$prop = $set ) ; how to reset property with an var... investigate.. EndFunc If you want the XML with the translate function, please get it from the github, ty https://github.com/bustix/Internal-Framework Hope you like it. Btw. next part is to get the cookies with XML working and to enable an login functionality - later i will also start adding parsing to the XML and multi processing, but - step by step (as my regex skills are no way present - i have to ninja the forums for good examples) If you have any questions or need assistance, feel free to ask them - i'll try to answer them as good as i can. Edit [20.05.19]: Updated: XML_Core.au3 XML_Object.au3 Internal-Framework.au3 on the git repo Edited May 20, 2019 by Busti My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity 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