Sign in to follow this  
Followers 0
Eemuli

AutoItObject - How to use .Create() ?

7 posts in this topic

I am using

I have created an object and I would like other object to inherit the first one. Here is the code:

#include "AutoitObject.au3"
Opt("MustDeclareVars", 1)

; Error monitoring
Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc")

; Initialize AutoItObject
_AutoItObject_StartUp()

; Create Object
Global $oObject = _SomeObject()
Global $oClone = _cloneObject()

; Set some property
$oObject.Title = "Hey"

;Display messagebox
$oObject.MsgBox("Test")

$oClone.Title = "Cloned"
$oClone.MsgBox("Clone object")

; Relese
$oObject = 0 ; <-!Comment this out to see the new behavior!

; That's it! Goodby



; Define object
Func _SomeObject()
    Local $oClassObject = _AutoItObject_Class()
    $oClassObject.Create()
    $oClassObject.AddMethod("MsgBox", "_Obj_MsgBox")
    $oClassObject.AddProperty("Title", $ELSCOPE_PUBLIC, "Something")
    $oClassObject.AddProperty("Text", $ELSCOPE_PUBLIC, "Some text")
    $oClassObject.AddProperty("Flag", $ELSCOPE_PUBLIC, 64 + 262144)
    $oClassObject.AddDestructor("_DestructorForSomeObject")
    Return $oClassObject.Object
EndFunc   ;==>_SomeObject

Func _Obj_MsgBox($oSelf, $string)
    MsgBox($oSelf.Flag, $oSelf.Title, $string)
EndFunc   ;==>_Obj_MsgBox

Func _DestructorForSomeObject($oSelf)
    ConsoleWrite("!...destructing..." & @CRLF)
EndFunc

Func _ErrFunc()
    ConsoleWrite("! COM Error !  Number: 0x" & Hex($oError.number, 8) & "   ScriptLine: " & $oError.scriptline & " - " & $oError.windescription & @CRLF)
    Return
EndFunc   ;==>_ErrFunc

Func _cloneObject()
    Local $oClass = _AutoItObject_Class()

    With $oClass
        .Create($oObject)
    EndWith

    Return $oClass.Object
EndFunc

For some reason $oClone doesnt inherit $oObject. Code returns "! COM Error ! Number: 0x8002000E ScriptLine: 59 - Invalid number of parameters." (Line 59 = .Create($oObject))

even though in help file it says that $oParent parameter can be given for .Create() method. => "Create([$oParent = 0]) - creates AutoItObject object"

I know I can use _AutoItObject_Create($oObject) and that one works fine, but why doesnt .Create($oObject) ?

Am I doing something wrong?

Im using AutoIt version v3.3.8.0 and

AutoItObject UDF version v1.2.8.2.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Use _AutoItObject_AddMethod() and ...AddProperty() in the class which inherits from another class.

For instance, if you have a class which defines some methods and you want another class to inherit those methods. So, class_one() defines a method and class_two() wants to use that method then put Local $this = class_one()) inside of class_two().

#AutoIt3Wrapper_AU3Check_Parameters=-w 1 -w 2 -w 3 -w 4 -w 6 -w 7 -d

#include "AutoitObject.au3"

_AutoItObject_StartUp()

Global $concrete = concrete_class()

$concrete.HelloWorld()

$concrete.HelloWorldAgain()

$concrete = ''

_AutoItObject_Shutdown()

; -------------------------------------------------------------------------------------------------

Func abstract_class()
    Local $this = _AutoItObject_Class()
    $this.AddMethod("HelloWorld", "abstract_hello_world")
    $this.AddDestructor("abstract_dtor")
    Return $this.Object
EndFunc

Func abstract_dtor(Const $this)
    MsgBox(0, "Abstract", "Destructed")
    Return $this
EndFunc

Func abstract_hello_world(Const $this)
    MsgBox(0, "Abstract", "Hello World")
    Return $this
EndFunc

; -------------------------------------------------------------------------------------------------

Func concrete_class()
    Local $this = abstract_class()
    _AutoItObject_AddMethod($this, "HelloWorldAgain", "concrete_hello_world_again")
    _AutoItObject_AddDestructor($this, "concrete_dtor")
    Return $this
EndFunc

Func concrete_dtor(Const $this)
    MsgBox(0, "Concrete", "Destructed")
    Return $this
EndFunc

Func concrete_hello_world_again(Const $this)
    MsgBox(0, "Concrete", "Hello World Again")
    Return $this
EndFunc

; -------------------------------------------------------------------------------------------------

Heavily edited due to giving totally wrong answer first few times around.

Edited by LaCastiglione

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Use _AutoItObject_AddMethod() and ...AddProperty() in the class which inherits from another class.

For instance, if you have a class which defines some methods and you want another class to inherit those methods. So, class_one() defines a method and class_two() wants to use that method then put Local $this = class_one()) inside of class_two().

Indeed, that is working and you can also do it like this:

#AutoIt3Wrapper_AU3Check_Parameters=-w 1 -w 2 -w 3 -w 4 -w 6 -w 7 -d

#include "AutoitObject.au3"

_AutoItObject_StartUp()

Global $abstract = abstract_class()
Global $concrete = concrete_class()

$concrete.HelloWorld()

$concrete.HelloWorldAgain()

$concrete = ''

_AutoItObject_Shutdown()

; -------------------------------------------------------------------------------------------------

Func abstract_class()
    Local $this = _AutoItObject_Class()
    $this.AddMethod("HelloWorld", "abstract_hello_world")
    $this.AddDestructor("abstract_dtor")
    Return $this.Object
EndFunc

Func abstract_dtor(Const $this)
    MsgBox(0, "Abstract", "Destructed")
    Return $this
EndFunc

Func abstract_hello_world(Const $this)
    MsgBox(0, "Abstract", "Hello World")
    Return $this
EndFunc

; -------------------------------------------------------------------------------------------------

Func concrete_class()
    Local $this = _AutoItObject_Create($abstract)
    _AutoItObject_AddMethod($this, "HelloWorldAgain", "concrete_hello_world_again")
    _AutoItObject_AddDestructor($this, "concrete_dtor")
    Return $this
EndFunc

Func concrete_dtor(Const $this)
    MsgBox(0, "Concrete", "Destructed")
    Return $this
EndFunc

Func concrete_hello_world_again(Const $this)
    MsgBox(0, "Concrete", "Hello World Again")
    Return $this
EndFunc

; -------------------------------------------------------------------------------------------------

But now the question remains - why cant it be done like this:

#AutoIt3Wrapper_AU3Check_Parameters=-w 1 -w 2 -w 3 -w 4 -w 6 -w 7 -d

#include "AutoitObject.au3"

_AutoItObject_StartUp()

Global $abstract = abstract_class()
Global $concrete = concrete_class()

$concrete.HelloWorld()

$concrete.HelloWorldAgain()

$concrete = ''

_AutoItObject_Shutdown()

; -------------------------------------------------------------------------------------------------

Func abstract_class()
    Local $this = _AutoItObject_Class()
    $this.AddMethod("HelloWorld", "abstract_hello_world")
    $this.AddDestructor("abstract_dtor")
    Return $this.Object
EndFunc

Func abstract_dtor(Const $this)
    MsgBox(0, "Abstract", "Destructed")
    Return $this
EndFunc

Func abstract_hello_world(Const $this)
    MsgBox(0, "Abstract", "Hello World")
    Return $this
EndFunc

; -------------------------------------------------------------------------------------------------

Func concrete_class()
    Local $this = _AutoItObject_Class()
    $this.Create($abstract)
    $this.AddMethod($this, "HelloWorldAgain", "concrete_hello_world_again")
    $this.AddDestructor($this, "concrete_dtor")
    Return $this.Object
EndFunc

Func concrete_dtor(Const $this)
    MsgBox(0, "Concrete", "Destructed")
    Return $this
EndFunc

Func concrete_hello_world_again(Const $this)
    MsgBox(0, "Concrete", "Hello World Again")
    Return $this
EndFunc

; -------------------------------------------------------------------------------------------------

According to the help file both ways presented above should be correct. Only problem is that you cant use any parameters with "$this.create()" method.

Does above scripts work on your computer?

[EDIT] Some syntax errors in code.

Edited by Eemuli

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I would file a bug report over at the AIO project page.

Indeed, that is working and you can also do it like this:

Indeed. This does work. However, for me it calls the dtor for abstract twice.

According to the help file both ways presented above should be correct. Only problem is that you cant use any parameters with "$this.create()" method. Does above scripts work on your computer?

Just fix up your syntax if you decide to use your second example...

#AutoIt3Wrapper_AU3Check_Parameters=-w 1 -w 2 -w 3 -w 4 -w 6 -w 7 -d

#include "AutoitObject.au3"

_AutoItObject_StartUp()

Global $abstract = abstract_class()
Global $concrete = concrete_class()

$concrete.HelloWorld()

$concrete.HelloWorldAgain()

$concrete = ''

_AutoItObject_Shutdown()

; -------------------------------------------------------------------------------------------------

Func abstract_class()
    Local $this = _AutoItObject_Class()
    $this.AddMethod("HelloWorld", "abstract_hello_world")
    $this.AddDestructor("abstract_dtor")
    Return $this.Object
EndFunc

Func abstract_dtor(Const $this)
    MsgBox(0, "Abstract", "Destructed")
    Return $this
EndFunc

Func abstract_hello_world(Const $this)
    MsgBox(0, "Abstract", "Hello World")
    Return $this
EndFunc

; -------------------------------------------------------------------------------------------------

Func concrete_class()
    Local $this = _AutoItObject_Class()
    $this.Create($abstract)
    $this.AddMethod("HelloWorldAgain", "concrete_hello_world_again")
    $this.AddDestructor("concrete_dtor")
    Return $this.Object
EndFunc

Func concrete_dtor(Const $this)
    MsgBox(0, "Concrete", "Destructed")
    Return $this
EndFunc

Func concrete_hello_world_again(Const $this)
    MsgBox(0, "Concrete", "Hello World Again")
    Return $this
EndFunc

; -------------------------------------------------------------------------------------------------
Edited by LaCastiglione

Share this post


Link to post
Share on other sites

Hi,

I have the same problem on Win Xp,

i have show your post on http://autoitobject.origo.ethz.ch/issues

So for me, the way is to redefine the "_AutoItObject_Class()" fonction

I have write a customized _AutoItObject_Class with oParent parameter :

;================================================================================================
; Customized Class Object
;=====================================================================================================
Func _AutoitObj_Class($oParent)
Local $oThis = _AutoItObject_Create()
_AutoItObject_AddMethod($oThis, "AddProperty", "_Object_AddProperty")
_AutoItObject_AddMethod($oThis, "AddMethod", "_Object_AddMethod")
_AutoItObject_AddMethod($oThis, "Create", "_Object_Create")
_AutoItObject_AddProperty($oThis, "Object", $ELSCOPE_PUBLIC, 0)
_AutoItObject_AddProperty($oThis, "Parent", $ELSCOPE_PUBLIC, $oParent)
Return $oThis
EndFunc

and the customized fonction :

Func _Object_Create($oSelf)
$oSelf.Object = _AutoItObject_Create($oSelf.Parent)
EndFunc
Func _Object_AddMethod($oSelf, $Name, $Fonction)

Local $oObject = $oSelf.Object
_AutoItObject_AddMethod($oObject, $Name, $Fonction)
EndFunc
Func _Object_AddProperty($oSelf, $Name, $Scope, $Value)
Local $oObject = $oSelf.Object
_AutoItObject_AddProperty($oObject, $Name, $Scope, $Value)
EndFunc

For use it you just have to :

Global $oMyObject = _MyObject()
$oMyObject.MyMethod

Func _MyObject($oParent=0)
Local $oClass = _AutoitObj_Class($oParent)
$oClass.Create
$oClass.AddProperty("MyProperty", $ELSCOPE_PUBLIC, 4)
$oClass.AddMethod("MyMethod", "testMyMethod")
Return $oClass.Object
EndFunc
Func testMyMethod($oSelf)
MsgBox(0, "", "MyProperty = "&$oSelf.MyProperty)
EndFunc

FOR ME IT WORK with Parameter $oParent

If you have suggestion for the code please post it

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Sorry,

i correct some mistake

So for me, the way is to redefine the "_AutoItObject_Class()" fonction

I have write a customized _AutoItObject_Class with oParent parameter :

;================================================================================================
; Customized Class Object
;=====================================================================================================
Func _AutoitObj_Class($oParent)
Local $oCustom = _AutoItObject_Create()
      _AutoItObject_AddMethod($oCustom, "AddProperty", "_Object_AddProperty")
      _AutoItObject_AddMethod($oCustom, "AddMethod", "_Object_AddMethod")
      _AutoItObject_AddMethod($oCustom, "Create", "_Object_Create")
      _AutoItObject_AddProperty($oCustom, "Object", $ELSCOPE_PUBLIC, 0)
      _AutoItObject_AddProperty($oCustom, "Parent", $ELSCOPE_PUBLIC, $oParent)
Return $oCustom
EndFunc

and the customized fonction :

;=================================================================================
; Customized Fonction Create - Class Object
;=======================================================================================Func _Object_Create($oSelf)
     $oSelf.Object = _AutoItObject_Create($oSelf.Parent)
EndFunc

;=======================================================================================
; Customized Fonction AddMethod - Class Object
;=======================================================================================
Func _Object_AddMethod($oSelf, $Name, $Fonction)
     Local $oObject = $oSelf.Object
     _AutoItObject_AddMethod($oObject, $Name, $Fonction)
EndFunc


;======================================================================================
; Customized Fonction AddProperty - Class Object
;=======================================================================================
Func _Object_AddProperty($oSelf, $Name, $Scope, $Value)
     Local $oObject = $oSelf.Object
     _AutoItObject_AddProperty($oObject, $Name, $Scope, $Value)
EndFunc

Example For use it you just have to :

#include <AutoItObject.au3>
Global $oParent
_AutoItObject_Startup()

;// Obj 1
Global $oMyObject1 = _AutoItObject_Create()
_AutoItObject_AddProperty($oMyObject1, "MyProperty_Obj1", $ELSCOPE_PUBLIC, "Object 1")

;// Obj 2 with parent Obj 1
Global $oMyObject2 = _MyObject($oMyObject1)
$oMyObject2.MyMethod

;// Class definition Obj 2
Func _MyObject($oParent=0)
Local $oClass = _AutoitObj_Class($oParent)
$oClass.Create
$oClass.AddProperty("MyProperty_Obj2", $ELSCOPE_PUBLIC, "Object 2")
$oClass.AddMethod("MyMethod", "testMyMethod")
$oCustom = 0 ; delete the custom object
Return $oClass.Object
EndFunc

;// Methode obj 2
Func testMyMethod($oSelf)
MsgBox(0, "", "MyProperty_Obj1 = "&$oSelf.MyProperty_Obj1 &@CRLF& _
"MyProperty_Obj2 = "&$oSelf.MyProperty_Obj2 )
EndFunc

FOR ME IT WORK with Parameter $oParent

If you have suggestion for the code please post it

Edited by M2C

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
Sign in to follow this  
Followers 0

  • Similar Content

    • genius257
      By genius257
      First of all I've been searching on the forum, and while there's been done something like this with: https://www.autoitscript.com/forum/topic/141004-comobject-proxy-seamless-windows-script-control-autoitobj/
      I could not find any solution to my predicament.
       
      Is it possible to throw an error in a ScriptControl object, via AutoIt?
      I have a script, where AutoIt calls ScriptControl:JavaScript which in turn calls AutoIt.
      However i would like to be able to make AutoIt invoke an exception within ScriptControl, if the called functionality fails.
      Here's some code for reference:
      #AutoIt3Wrapper_Run_AU3Check=n #include-once #include "AutoitObject.au3" #include <WinAPIDiag.au3> $oJS = ObjCreate("ScriptControl") $oJS.Language = "JScript" $oJS.TimeOut = 0; A value of 0 means that the ScriptControl will monitor the execution of the script and will trigger the Timeout event if it determines that the script is hung. _AutoItObject_Startup() $oAutoIt = _AutoItObject_Create() _AutoItObject_AddMethod($oAutoIt, "Execute", "_Execute", False) $oJS.AddObject("AutoIt", $oAutoIt, True) OnAutoItExitRegister("_CleanUp") $_AutoItError = ObjEvent("AutoIt.Error", "_AutoItError") Func _CleanUp() ConsoleWrite("Cleaning up..."&@CRLF) $oJS = 0 $oAutoIt = 0 _AutoItObject_Shutdown() EndFunc Func _Execute($oSelf, $sString) $vReturn = Execute($sString) If @error<>0 Then Return $oJS.Eval("throw new SyntaxError();"); Does invoke exception, but not within the try/catch Return $vReturn EndFunc Func _AutoItError($oError) $oError2 = $oJS.Error ConsoleWrite( _ "Column: " & $oError2.Column & @CRLF & _ "Description: " & $oError2.Description & @CRLF & _ "HelpContext: " & $oError2.HelpContext & @CRLF & _ "HelpFile: " & $oError2.HelpFile & @CRLF & _ "Line: " & $oError2.Line & @CRLF & _ "Number: " & $oError2.Number & @CRLF & _ "Source: " & $oError2.Source & @CRLF & _ "Text: " & $oError2.Text & @CRLF _ ) $oError2.Clear() EndFunc $oJS.Eval("(function(){"& _ "try{"& _ "AutoIt.Execute('MsgBox(0,\'\', \'a\')');"& _ "AutoIt.Execute('a.b');/*error should occur here*/"& _ "AutoIt.Execute('MsgBox(0,\'\', \'b\')');"& _ "}catch(e){"& _ "AutoIt.Execute('ConsoleWrite(\'Error\'&@CRLF)');"& _ "}"& _ "})()")  
    • tarretarretarre
      By tarretarretarre
      Now its my turn to give back to the community ( Better late than never :P)..
       
      First i want to thank progAndy for his amazing UDF which this idea came from

       
      And the AutoitObject Team (For making autoit fun again)
       

      I dont have so much to say more thant to let the project speak for itself, ive had this for a couple of months but it was "integrated" into my own "framework" but today I decided to release it because i have seen some people on the forum search for something like this.
      What libraries does this use and are they included?
      Connector/C 6.1.6 ( https://dev.mysql.com/downloads/connector/c/ ) And yes, they are included in the download so nothing has to be installed or anything

      What are the features:
      Prepared statements 32 and 64 bit environment Multiline prepared statements  Simplicity User-friendly PDO-like Syntax & Methods (http://php.net/pdo)  
      So whats the difference between this and x's Mysql UDF?
      When you are fetching your data from your database, you use your table-names to display them, like this:
      with $MySql Local $Vars = ["?", $lastname, "?", $age] .prepare("SELECT id, surname, lastname FROM users WHERE lastname = ? AND AGE > ?") .execute($Vars) Consolewrite(stringformat("Searchresult: %d Hits", .rowCount()) for $row in $oRows consolewrite("Surname: " & $row.surname & @crlf) consolewrite("Lastname: " & $row.lastname & @crlf) next endwith  
      Function-list (Yeah i might improve this when i have time)
      ; Every parameter is a default value of method _miniSQL_setDllDir(@ScriptDir); returns nothing Local Const $MySql = _miniSQL_LoadLibrary(); Returns object with methods ; Starts the library, connects to the database and returns the object $MySql.Startup($sHost, $sUser, $sPass = "", $sDatabase = "", $iPort = 0, $sUnix_socket = "", $iClient_Flag = 0); Returns TRUE if connection was succeded otherwise FALSE ; Shuts down the library and prevents any methods to be executed $MySql.Shutdown() ; The desired SQL query goes here (SELECT x FROM table) $MySql.prepare($sQuery); Returns nothing ; Used for multi-line prepared statements (See Example3 - newline prepared statements) $MySql.PrepareGlue($sQuery); Returns nothing ; Cleans any previous prepared statement of any kind $MySql.PrepareClean(); Returns nothing ; Executes a prepared statement of any kind, with or without passed arguments $MySql.execute($aVars = Null, $iExecuteStyle = $_miniSQL_ExecuteStoreResult); returns TRUE if success, otherwise FALSE ; Options for $iExecuteStyle: $_miniSQL_ExecuteStoreResult = 0 and $_miniSQL_ExecuteOnly = 1 ; Fetches previous executed prepared statement (If anything was stored "see Options for iExecuteStyle") $MySql.fetchAll($iFetchStyle = $_miniSQL_FetchObject); Returns (Depends on $iFetchStyle) ; Options for $iFetchStyle: $_miniSQL_FetchObject = 0 (Default), $_miniSQL_FetchSingleObject = 1, $_miniSQL_FetchArray = 2, $_miniSQL_FetchSingleValue = 3 ; Gives you the "lastinsertId" (The last id that was affected) $MySql.lastInsertId(); Returns the last affected id ; Counts the affected rows done by any MySQL operation (INSERT\SELECT\UPDATE\DELETE) $MySql.rowCount(); Returns how affected rows ; Use this if want to know why nothing is working (Can be used anywhere after $MySql.Startup()) $MySql.debug(); Returns nothing ; Retrives the last MysqlError set $MySql.SQLerror(); Returns error (If any) Here is some example code:
      #include <miniSQL\miniSQL.au3> ; Set default dir for our dlls (Only has to be done once) _miniSQL_setDllDir(@ScriptDir & "\miniSQL") ; Declared as CONST since we never want to accidentally change the variables original value Local Const $MySql = _miniSQL_LoadLibrary() ;Connect to database & Init library If Not $MySql.Startup("localhost", "user", "pass", "db", 3306) Then MsgBox(0, "Failed to start library", $MySql.debug()) Exit EndIf With $MySql .prepare("SELECT * FROM members") If Not .execute() Then MsgBox(0, "Failed to execute query", .sqlError()) Local $oRows = .fetchAll() ; Print how many rows got affected by latest query ConsoleWrite(StringFormat("Number of rows to display: %s", .rowCount()) & @CRLF) ; we use isObj to check if we got any result. If IsObj($oRows) Then For $row In $oRows ConsoleWrite(StringFormat("Id: %s", $row.id) & @CRLF) ConsoleWrite(StringFormat("Name: %s", $row.name) & @CRLF) ConsoleWrite(StringFormat("Bio: %s", $row.bio) & @CRLF) Next Else ConsoleWrite("No rows to show"&@CRLF) EndIf EndWith ; Use this in your app when you are done using the database $MySql.Shutdown() #include <miniSQL\miniSQL.au3> ; Set default dir for our dlls (Only has to be done once) _miniSQL_setDllDir(@ScriptDir & "\miniSQL") ; Declared as CONST since we never want to accidentally change the variables original value Local Const $MySql = _miniSQL_LoadLibrary() ;Connect to database & Init library If Not $MySql.Startup("localhost", "user", "pass", "db", 3306) Then MsgBox(0, "Failed to start library", $MySql.debug()) Exit EndIf With $MySql ; We use an array to make our query look nicer Local $vars = [":name", @UserName&Random(1,10,1)] ; Prepare our statement .prepare("UPDATE members SET name = :name WHERE 1") If Not .execute($vars) Then MsgBox(0, "Failed to execute query", .sqlError()) ; Print how many rows got affected by latest query ConsoleWrite(StringFormat("Example 1 rows affected: %s", .rowCount()) & @CRLF) EndWith ; We can also prepare like this With $MySql Local $vars = ["?", @UserName, "?", 1] ; Prepare our statement .prepare("UPDATE members SET name = ? WHERE id = ?") If Not .execute($vars) Then MsgBox(0, "Failed to execute query", .sqlError()) ; Print how many rows got affected by latest query ConsoleWrite(StringFormat("Example 2 rows affected: %s", .rowCount()) & @CRLF) EndWith ; Use this in your app when you are done using the database $MySql.Shutdown()  
      With $MySql ; We use an array to make our query look nicer Local $vars = ["?", 1] ;Line by line prepared statement .prepareClean(); .prepareGlue("SELECT *") .prepareGlue("FROM members") .prepareGlue("WHERE id = ?") If Not .execute($vars) Then MsgBox(0, "Failed to execute query", .sqlError()) ; Print how many rows got affected by latest query ConsoleWrite(StringFormat("Example 1 rows affected: %s", .rowCount()) & @CRLF) EndWith ; Use this in your app when you are done using the database $MySql.Shutdown() Some code from one of my applications at work using this UDF
      With $MySql .prepareClean() .prepareGlue("SELECT") .prepareGlue("cases.cases_dedu_casenumber,") .prepareGlue("cases.cases_created_by_ugid,") .prepareGlue("cases.cases_dedu_ftg,") .prepareGlue("cases.cases_date_created,") .prepareGlue("cases.cases_date_finished,") .prepareGlue("cases.cases_protocol_director,") .prepareGlue("cases.cases_finished_by_ugid,") .prepareGlue("IFNULL(uid1.names_name, 'none') as createdByFullname,") .prepareGlue("IFNULL(uid2.names_name, 'none') as finishedByFullname") .prepareGlue("FROM cases") .prepareGlue("LEFT JOIN names AS uid1") .prepareGlue("ON cases.cases_created_by_ugid = uid1.names_uid") .prepareGlue("LEFT JOIN names AS uid2") .prepareGlue("ON cases.cases_finished_by_ugid = uid2.names_uid") if $_App_Case_SearchFor Then .prepareGlue(StringFormat("WHERE cases_dedu_casenumber LIKE '%s'",$_App_Case_SearchFor)) .prepareGlue("ORDER BY cases.cases_date_created DESC") .prepareGlue("LIMIT 0, 30") if not .execute() then return __ThrowException(.sqlError()) Local $oRows = .fetchAll() EndWith  
       
      Git: https://gitlab.com/xdtarrexd/MiniSQL.git
      Download: Zip generated from Github
       
      Feel free to open your mind about this
    • therms
      By therms
      If you don't like dealing with Scripting.dictionary you might want to try out this thing I whipped up yesterday evening and this morning.
      Basically just a simple wrapper around Scripting.dictionary to make the API a little bit less stupid.  By "stupid" I mean "not like the awesome Python dict API".
      Created for the following reasons..
      Wanted to get a basic understanding of AutoItObject. Wanted to get a basic understanding of the Micro unit test framework. As of 11/4/2014 AutoIt Stable has no native dict or associative array type.  A >Map type is in the current AutoIt beta. It's laborious to use Scripting.dictionary all the time. The Python dict API is better than Scripting.dictionary's I thought about writing my own hash table implementation in AutoIt, but on balance I decided it wasn't worth the effort and just stuck to Scripting.dictionary to save time/effort.
      As you can see I've got a decent number of unit tests for such a simple implementation, so it should be quite robust.
      #include <Dict2.au3> #include <Array.au3> $dict = _DictCreate() ConsoleWrite($dict.len()) ; Outputs 0 $dict.set("key1", "value1") $dict.set("key2", "value2") $dict.set("key3", "value3") $dict.set("key4", 1) ConsoleWrite($dict.get("key2")) ; Outputs 'value2' ConsoleWrite($dict.len()) ; Outputs 3 ConsoleWrite($dict.contains("key2") ; Outputs True $dict.set("key4", $dict.get("key4") + 1) ConsoleWrite($dict.get("key4")) ; Outputs 2 $dict.del("key4") ConsoleWrite($dict.contains("key4")) ; Outputs False $aPairs = $dict.pairs() _ArrayDisplay($aPairs) ; Displays 2d array with column one contains keys, and column two ; containing associated values $aKeys = $dict.keys() _ArrayDisplay($aKeys) ; Displays array containing all keys $aValues = $dict.values() _ArrayDisplay($aValues) ; Displays array of all values $aDesiredKeys = ["key1", "key3"] $aValues = $dict.values($aDesiredKeys) _ArrayDisplay($aValues) ; Displays array of values for key1 and key3 GET IT HERE
    • SirJohann
      By SirJohann
      Hi guys, I've been working with AutoItObject and I'm curious about a thing.
      This code:
      #include 'AutoItObject.au3' _AutoItObject_Startup() Global $_oBasicObject = _AutoItObject_Create() _AutoItObject_AddProperty($_oBasicObject, 'prop', $ELSCOPE_PUBLIC, _AutoItObject_Create($_oBasicObject)) Ok, when you use _AutoItObject_Create you can copy all the properties from another object, but now he is copying himself, so the value of $_oBasicObject.prop will be another object with an exact property and is a loop or what? Then $_oBasicObject.prop.prop.prop is another object with another prop?
    • MarkRobbins
      By MarkRobbins
      In my >previous adventures, I got a bare-bones AutoIt proxy object injected into MSScriptControl.ScriptControl.
      The proxy had just enough functionality that a basic form application could be coded from Javascript. That was kind of fun but the ScriptControl is old and iffy, its environment is like using an old version of JScript, sometimes mere comments would trigger non-compilation.
      What would be really good is to get a full-fledged proxy injected into IE, so that you had ECMA5-ish language features and a more stable platform. I had no idea how to do this though, so I was shocked when it worked, which is why I call it 'smuggling'.
      Once you had a decked out proxy in there, you could code your entire app in Js, and use IE as a GUI (or not). I am most interested in coding in an OOP language, so that is what is driving my attempts.
      Long story short, it worked. So now I have an initial framework for doing this, and I put together this stress test of an application and demo.
      The clip from the header:
      ; OVERVIEW ; Name: Jsaioie -- Javascript, AutoItObject, Internet Explorer ; ; This is an advanced demo of using an embedded IE control as a GUI. ; What is noteworthy is that the main application code is in javascript, which makes calls ; to core AutoIt functions via an imported AutoItObject which has been constructed. ; This means that virtually all of the application can be coded as JS, which means OOP. ; JS OOP is really not demonstrated here within this demo however. ; ; What is demonstrated in the JS code is how JS can be persuaded to behave asynch, and emulate ; a threaded application. ; ; When the application starts, it will analyze all the files in the users AutoIt include directory in order ; to build a series of collapsable divs with information on the constants and functions found. ; While this process is occuring, the UI is still relatively responsive, and you can watch the nested div ; items being added, or even filter them while it is loading. ; ; The application will pick up about 14k identifiers from the include directory, each having its own div ; and tt tag containing documentation. Some research shows that IE8 has problems when the div count exceeds ; 1000, but I am using IE 10. Your results will depend on your IE version. It is said that IE9+ should have ; not much problem with 100k divs. The real lag is filtering them, which could be optimized. ; ; Parsing the files, loading and building html and listeners for 14k items takes 5.5 minutes on my machine. ; That breaks down to 42 items per second, or 24k bytes per second. Tweaking seems to have no effect. The ; goal is to keep the thing responsive during load, the html I mean, but the application will hourglass ; when it encounters the bigger files, probably a IO thing. ; ; The application consists of the following files: ; Jsaioie.au3 - Backbone code file ; Jsaioie.au3.ini - Config, will be created ; Jsaioie.au3.js - Application code ; Jsaioie.au3.html - Simple html skeleton ; Jsaio-inc-AiFn.au3 - Constructs the AutoIt proxy AutoItObject ; Jsaio-utils.au3 - Some misc utils ; jquery-1.10.2.js - For dom manipulation ; Jsaioie.au3.log.txt - Output log for debugging ; Jsaio-loaded.js - A preview of the javascipt to be loaded after preprocessing ; ; OPERATION ; 1. $AutoItForCom AutoItObject is created and core AutoIt functionality appended to it ; 2. Small amount of application specific functionality is also appended ; 3. Form with Embedded IE constructed ; 4. Html is constructed from assets, preprocessed and injected into IE ; 5. $AutoItForCom is injected into IE (the real magic part) ; 6. Javascript init() function is called which grabs the injected $AutoItForCom and assigns it to window.A var ; 7. Javascript Main() function is called which begins the application ; ; JAVASCRIPTS USE OF $AutoItForCom ; 1. Getting file list from include directory ; 2. Getting file contents ; 3. Logging ; 4. Running a specified editor to edit file ; 5. Placing text on clipboard ; 6. Reading config ini ; 7. Browse for folder ; 8. Browse for file ; 9. Getting ScriptFullPath ; 10. Checking @Error ; ; FEATURES ; 1. Dynamic html nested accordian browser ; 2. Filter for file, or for identifier ; 3. Up Down, Page Up Page Down keys while in filter boxes will scroll document ; 4. Clear filter will collapse all ; 5. Click on Icon to copy signatures to clip ; 6. Unfold Items to see documentation if exists ; 7. Click on file link to edit file ; 8. Specify your editor, saved in config ; 9. Specify your include dir, saved in config ; 10. Asynch loading, file icons change color ; ; NOTES ; This is not intended to be a finished app, but a stess test and demo. A lot of the JS coding has been ; unrolled and exposed in a simplistic manner for illustration purposes. Familiarity with Javascript and ; jQuery are neccessary for understanding how the application works. All the AutoIt code is essentially ; a framework so that it is possible to code the app in the browser, and have access to autoit. And a pretty pic:

      And the zip:
      Jsaioie.zip