Jump to content

Recommended Posts

Posted

I've been looking at this now, seeing what all I can use it for, and so far I like it. I do have one question.

Is it possible to define a default method for an object? As in, the Scripting.Dictionary can access items using either the .Item() method, or just by calling the object directly:

Of course. Add method "__default__". Something like:

AddMethod("__default__", "_YourMethod")

♡♡♡

.

eMyvnE

Posted (edited)

Awesome, that works well.

Except inside another autoitobject. I tried setting one object as a property in another object, then calling the propery using just the (), and I get "The requested action with this object has failed."

Adding an error handler, I get "Invalid number of parameters." I may be doing something else wrong though...

Edit: Ok, here's a small reproducer that doesn't error out, but doesn't work as I thought it should.

#include "AutoitObject.au3"
_AutoItObject_StartUp()
Func _Class1()
Local $obj = _AutoItObject_Class()
$obj.AddMethod("__default__", "Hello")
Return $obj.Object
EndFunc
Func _Class2()
Local $obj = _AutoItObject_Class()
$obj.AddProperty("test", $ELSCOPE_PUBLIC, _Class1())
Return $obj.Object
EndFunc
Func Hello($self)
ConsoleWrite("Hello" & @CRLF)
EndFunc
ConsoleWrite("Test Class 1" & @CRLF)
$temp = _Class1()
$temp()
$temp = 0
ConsoleWrite("Test Class 2" & @CRLF)
$temp = _Class2()
$temp.test()
ConsoleWrite("Test Class 2b" & @CRLF)
$temp2 = $temp.test
$temp2()
$temp = 0

It should print Hello all 3 times, but it misses Test 2, without an error. I'll have to figure out my Params error later, if I find an answer to this.

Edited by SkinnyWhiteGuy
Posted (edited)

Well, I tried that, and added an option parameter to the default function, and still have errors.

Here is the latest code I have:

#include "AutoitObject.au3"
 
; Error monitoring
Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc")
 
Func _ErrFunc()
    ConsoleWrite("! COM Error !  Number: 0x" & Hex($oError.number, 8) & "   ScriptLine: " & $oError.scriptline & " - " & $oError.windescription & @CRLF)
    Return
EndFunc   ;==>_ErrFunc
 
_AutoItObject_StartUp()
 
Func _Class1()
Local $obj = _AutoItObject_Class()
 
$obj.AddMethod("__default__", "Hello")
$obj.AddDestructor("Goodbye")
 
Return $obj.Object
EndFunc
 
Func _Class2()
Local $obj = _AutoItObject_Class()
 
$obj.AddProperty("test", $ELSCOPE_PUBLIC, _Class1())
$obj.AddDestructor("Goodbye")
 
Return $obj.Object
EndFunc
 
Func Hello($self, $msg = "")
ConsoleWrite("Hello " & $msg & @CRLF)
EndFunc
 
Func Goodbye($self)
ConsoleWrite('Goodbye' & @CRLF)
EndFunc
 
ConsoleWrite("Test Class 1" & @CRLF)
$temp1 = _Class1()
$temp1("Test")
 
ConsoleWrite("Test Class 2" & @CRLF)
$temp2 = _Class2()
$temp2.test("Error")
 
ConsoleWrite("Test Class 2b" & @CRLF)
$temp3 = $temp2.test
$temp3("ReTest")

If I'm looking at it right, this may not be possible. $temp2.test could be a Method of _Class2 as well as the default Method for the test object held in the Property of _Class2. I'm not sure if that might be the issue at hand or not, though...

Edited by SkinnyWhiteGuy
Posted

If I'm looking at it right, this may not be possible. $temp2.test could be a Method of _Class2 as well as the default Method for the test object held in the Property of _Class2. I'm not sure if that might be the issue at hand or not, though...

There you go.

Save the object first and then call its default method.

♡♡♡

.

eMyvnE

Posted (edited)

Edit: Looks good :graduated: Still, why don't you implement a real hashtable just like scripting.dicionary? That would be faster.

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Posted

I was bored at work today, and the Linked List implementation seemed more straight forward at the time. I was thinking about taking Nutster's old UDF here on the forums, and putting it into Object form, and compare the two. We'll see how bored I am on Monday.

  • 7 months later...
Posted

Need help inherit AutoItObject from JScriptObject () or is it possible to inherit any COM object other than AutoItObject created COM object?

I have been playing with Kip's modified sample (), works with crafted object but seems failed to locate correct vtable (DllStructGetData($hHeader, 1) < 0 in ___AddMembersToLookupTable function) for other COM object (e.g. Scripting.Dictionary)

Thanks

Posted

Need help inherit AutoItObject from JScriptObject () or is it possible to inherit any COM object other than AutoItObject created COM object?

Modifying the JScript-Object does not save any overhead. A method call still has to go from an object to a DLLCallback and finally the requested AutoIt-function.

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Posted

Is there any way to pass an array to an object method as parameter?

I tried this example but fail:

#include <AutoItObject.au3>
#include <Array.au3>

_AutoItObject_Startup()

Dim $aArray[5] = [0,1,2,3,4]


$oAS = ActionScript()
$oAS.Run($aArray,'',True)

Func ActionScript()
    Local $oActionScript = _AutoItObject_Class()
    With $oActionScript
        .AddMethod('Run','__as_run')
        .AddProperty('Script',$ELSCOPE_PRIVATE,'')
    EndWith
    Return $oActionScript.Object
EndFunc

Func __as_run($oSelf,$aBitmap,$sPath,$bMem=False)
    If $bMem Then $sPath = $oSelf.Script
    Test($aBitmap,$sPath,$bMem)
EndFunc

Func Test($a,$b,$c)
    _ArrayDisplay($a)
    MsgBox(0,"",$<img src='http://www.autoitscript.com/forum/public/style_emoticons/<#EMO_DIR#>/cool.png' class='bbc_emoticon' alt='B)' />
    MsgBox(0,"",$c)
EndFunc
Posted

AutoITObject Team,

All links to the project homepage and documentation @ domain http://autoitobject.origo.ethz.ch/ are down.

ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search

Posted (edited)

Please stop playing with my ancient modified version.

Well actually I like your ancient one than the new complex as it simply helps me understand the basic concept. Thanks again Kip ;)

The problem is even the new AutoItObject ends up with the same fatal error if I try to inherit from another COM object.

A method call still has to go from an object to a DLLCallback and finally the requested AutoIt-function.

Agreed, but in JScript Object we need another wrapper (in pure javascript) which is worsen the case :)

My question is still, is it possible to inherit any COM object other than AutoItObject created COM object?

Edited by eimhym
Posted

Is there any way to pass an array to an object method as parameter?

I tried this example but fail:

#include <AutoItObject.au3>
#include <Array.au3>

_AutoItObject_Startup()

Dim $aArray[5] = [0,1,2,3,4]


$oAS = ActionScript()
$oAS.Run($aArray,'',True)

Func ActionScript()
    Local $oActionScript = _AutoItObject_Class()
    With $oActionScript
        .AddMethod('Run','__as_run')
        .AddProperty('Script',$ELSCOPE_PRIVATE,'')
    EndWith
    Return $oActionScript.Object
EndFunc

Func __as_run($oSelf,$aBitmap,$sPath,$bMem=False)
    If $bMem Then $sPath = $oSelf.Script
    Test($aBitmap,$sPath,$bMem)
EndFunc

Func Test($a,$b,$c)
    _ArrayDisplay($a)
    MsgBox(0,"",$<img src='http://www.autoitscript.com/forum/public/style_emoticons/default/cool.png' class='bbc_emoticon' alt='B)' />
    MsgBox(0,"",$c)
EndFunc
The question is: "What fails?"

Answer that (yes you can) and and you will see that your question doesn't even make sense.

♡♡♡

.

eMyvnE

Posted (edited)

The question is: "What fails?"

For example it fails to display the array in Test() function.

LE: sorry, yes it's work but for an unknown reason my array isn't displayed by _ArrayDisplay() function but the array is valid if I put there a message box to display an item from array. So it's not AutoIt Object UDF related question, I'll try to find what's wrong with _ArrayDisplay().

Edited by Andreik
Posted

Is it something about doing window messages when you are in a callback?

Silly me, it's right there in the first post!

Q. My GUI freezes! Why and how do I fix it? All methods are essentially dllcallbacks. Unfortunately this means that messages are not processed while your methods are being executed. As long as you keep your main loop outside any method, you'll be fine.

  • 3 weeks later...
Posted

Anyone know what is the latest version?

I note that the home page at http://autoitobject.origo.ethz.ch/ has been failing for several weeks.

The mirror has version 1.2.2.2 but in the past I downloaded version 1.2.8.2 from somewhere.

Is 1.2.8.2 the latest?

What is happening with http://autoitobject.origo.ethz.ch/ ?

Thanks

.... GOTOs? We don't need no stinkin' GOTOs! ....
Posted

Origo has shut down. Indeed, 1.2.8.2 is the most recent version, but I have no copies on my laptop. I'll have to look on my other computer, probably something is there. At least a version more recent than 1.2.2.0

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Posted (edited)

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...