gmp80 Posted November 5, 2014 Posted November 5, 2014 Hello All, firstly: AutoItObject is awesome, thank you @ProgAndy + Co Now my question: I can't seem to call objects registered using _AutoItObject_RegisterObject via Python scripts. I can however call the same object fine using PHP. Example code that registers the object Hello.Application: expandcollapse popup#include <Misc.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include "AutoitObject.au3" Func Hello($oSelf, $sName) $sText = "Hello "&$sName&"!" GUICtrlSetData($nEdit, $sText) Return $sText EndFunc Func Close() Exit EndFunc ; Initialize: _Singleton("Hello") Opt("TrayIconHide", 1) Opt("GUIOnEventMode", 1) ; Setup the COM interface: _AutoItObject_StartUp() $oObj = _AutoItObject_Class() $oObj.AddMethod("Hello", "Hello") $oComObj = $oObj.Object _AutoItObject_RegisterObject($oComObj, "Hello.Application") ; Show the GUI: GUICreate("Hello", 400, 45, -1, -1, $WS_CAPTION+$WS_POPUP+$WS_SYSMENU) GUISetOnEvent($GUI_EVENT_CLOSE, "Close") $nEdit = GUICtrlCreateEdit("", 10, 10, 380, 25, $ES_READONLY) GUISetState(@SW_SHOW) ; Main loop: While True Sleep(100) WEnd Example PHP code that works with the code above: <?php $hello = new COM("Hello.Application"); print $hello->Hello("Fred"); ?> Example Python code that doesn't work for me: import comtypes.client hello = comtypes.client.GetActiveObject("Hello.Application") print hello.Hello("Fred") I am a Python n00b, so I could easily be doing something wrong. This Python code does however work if Microsoft Word is running: import comtypes.client word = comtypes.client.GetActiveObject("Word.Application") Any pointers appreciated!
MikahS Posted November 5, 2014 Posted November 5, 2014 (edited) The reason it doesn't work is I think you are trying to call an Active Object, instead of creating the object like you do with new COM()l in PHP. EDIT: Heres your hint: it however works if Microsoft Word is running: So, only if there is already a word object running then, it works! So, you'll need to figure out how to create the object in python. Edited November 5, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
AdmiralAlkex Posted November 5, 2014 Posted November 5, 2014 Hello All, firstly: AutoItObject is awesome, thank you @ProgAndy + Co Now my question:I can't seem to call objects registered using _AutoItObject_RegisterObject via Python scripts.-snip- Any pointers appreciated!Hello, Welcome and thank you!Is it possible for you to try the win32com package instead? I know that worked earlier. >Access AutoIt (<-- example there). .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
gmp80 Posted November 6, 2014 Posted November 6, 2014 Thanks @AdmiralClaws! win32com does indeed work: import win32com.client hello = win32com.client.GetObject("Hello.Application") print hello.Hello("Fred")
Iczer Posted February 25, 2015 Posted February 25, 2015 i wanted to make some "two layered object" but cannot figure out how... something like this: $a1 = $oObj.SomeName.text $a2 = $oObj.SomeName.filename $a3 = $oObj.SomeName.width $a4 = $oObj.SomeName.style $a5 = $oObj.AnotherName.text $a6 = $oObj.AnotherName.filename $a7 = $oObj.AnotherName.width $a8 = $oObj.AnotherName.style is it possible?
jaberwacky Posted February 25, 2015 Posted February 25, 2015 Make an object with two properties: SomeName and AnotherName. Then make two objects each with their own properties and methods. Then assign one each to SomeName and AnotherName. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum?
jaberwacky Posted February 25, 2015 Posted February 25, 2015 This should work, but I've been up for twenty hours so far. This is also untested. expandcollapse popup#include "AutoItObject.au3" _AutoItObject_Startup() Global $obj = FirstObj() $Obj.SomeName.text $Obj.SomeName.filename $Obj.SomeName.width $Obj.SomeName.style $Obj.AnotherName.text $Obj.AnotherName.filename $Obj.AnotherName.width $Obj.SomeName.style Func FirstObj() Local $this = _AutoItObject_Class() $this.AddProperty("SomeName", $ELSCOPE_PUBLIC, SomeName()) $this.AddProperty("AnotherName", $ELSCOPE_PUBLIC, AnotherName()) Return $this.Object EndFunc Func SomeName() Local $this = _AutoItObject_Class() $this.AddProperty("text", $ELSCOPE_PUBLIC, '') $this.AddProperty("filename", $ELSCOPE_PUBLIC, '') $this.AddProperty("width", $ELSCOPE_PUBLIC, '') $this.AddProperty("style", $ELSCOPE_PUBLIC, '') Return $this.Object EndFunc Func AnotherName() Local $this = _AutoItObject_Class() $this.AddProperty("text", $ELSCOPE_PUBLIC, '') $this.AddProperty("filename", $ELSCOPE_PUBLIC, '') $this.AddProperty("width", $ELSCOPE_PUBLIC, '') $this.AddProperty("style", $ELSCOPE_PUBLIC, '') Return $this.Object EndFunc mLipok 1 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum?
kcvinu Posted July 22, 2015 Posted July 22, 2015 (edited) Hi ,It seems chinese for me. The example are very hard to understand. Edited September 29, 2015 by kcvinu Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only)
redrider81 Posted October 1, 2015 Posted October 1, 2015 (edited) Can someone tell me if the following is possible: Set a property equal to the result of an expression based on the values of other properties (upon instantiation)? The example below doesn't work, but I think it would be the most direct way to achieve my goal if it could work. Ideally, _self property should always be correct and accessible immediately after instantiation, without any additional manual commands required to set it. I've thought about creating getter and setter methods, but even then you would need two commands, one to create the object, one to populate the _self property. Example: Func _FolderHolder() Local $oClassObject = _AutoItObject_Class() With $oClassObject .Create() .AddProperty("path", $ELSCOPE_PUBLIC, @ScriptDir) .AddProperty("id", $ELSCOPE_PUBLIC, "Folder1") .AddProperty("_self", $ELSCOPE_PRIVATE, $oClassObject.path & "\" & $oClassObject.self) EndWith Return $oClassObject.Object EndFunc Edited October 1, 2015 by redrider81
redrider81 Posted October 1, 2015 Posted October 1, 2015 (edited) A perfectly acceptible workaround came to me , but of course only after I posted the question in the forum (See below). However, the question still warrants an answer however if anyone has time. I'm sure this could become an undesirable workaround in some cases. Func _FolderHolder($sPath = @ScriptDir, $sId = "Folder1") Local $oClassObject = _AutoItObject_Class() With $oClassObject .Create() .AddProperty("path", $ELSCOPE_PUBLIC, $sPath) .AddProperty("id", $ELSCOPE_PUBLIC, $sId) .AddProperty("_self", $ELSCOPE_PRIVATE, $sPath & "\" & $sId) EndWith Return $oClassObject.Object EndFunc Edited October 1, 2015 by redrider81
redrider81 Posted October 2, 2015 Posted October 2, 2015 (edited) Can anyone from the core team indicate if there is an elegant/easy method to do one of the following: Convert object directly to JSON string?Convert an object to any format of string? Return the properties of the object as an array or delimited string?Return the class name of the object created as a string? I'm trying to exchange my objects with ozmikes OO_JSON.au3 UDF . Thanks in advance. Edited October 2, 2015 by redrider81
Andreik Posted October 2, 2015 Posted October 2, 2015 I suppose you want to exchange objects definitions. The definition of the object it may be converted to a nice format but how would you deal with the methods implementation?
redrider81 Posted October 3, 2015 Posted October 3, 2015 Good question, and one I had thought about. I was just going to ignore them for my implementation because the only methods my AutoIt objects have are methods that save and retrieve data from the file system, and the only thing I'm doing with JSON objects is sending/receiving the properties. I don't have any dynamic JS methods to deal with. Thats fortunate... because to deal with the methods the proper way, would require something crazy, like creating a library that actually translates javascript functions to autoit functions and back. No way Jose. If I were to do that, I would more likely just do the program using pure OO_JSON, and make my methods JS methods, and not even using AutoIt objects or functions. To be honest, I would have done this already, but I don't know Javascript. I also was uncertain if dynamic JS methods in the OO_JSON framework could do all the same things that custom functions can do with AutoIt Objects.
tarretarretarre Posted November 9, 2015 Posted November 9, 2015 Is this project still being developed? AutoItObject.au3 Line: 1162 Func _AutoItObject_AddMethod(ByRef $oObject, $sName, $sAutoItFunc, $fPrivate = False) ; Author: Prog@ndy If Not IsObj($oObject) Then Return SetError(2, 0, 0) Local $iFlags = 0 If $fPrivate Then $iFlags = $ELSCOPE_PRIVATE DllCall($ghAutoItObjectDLL, "none", "AddMethod", "idispatch", $oObject, "wstr", $sName, "wstr", $sAutoItFunc, 'dword', $iFlags) If @error Then Return SetError(1, @error, 0) Return True EndFunc ;==>_AutoItObject_AddMethodWhy not do this instead?Func _AutoItObject_AddMethod(ByRef $oObject, $sName, $sAutoItFunc, $iFlags= $ELSCOPE_PUBLIC) ; Author: Prog@ndy If Not IsObj($oObject) Then Return SetError(2, 0, 0) DllCall($ghAutoItObjectDLL, "none", "AddMethod", "idispatch", $oObject, "wstr", $sName, "wstr", $sAutoItFunc, 'dword', $iFlags) If @error Then Return SetError(1, @error, 0) Return True EndFunc ;==>_AutoItObject_AddMethod Socket-IO - An event-driven TCP UDF (Realtime chat example) AutoIt-API-WS - An expressive HTTP server you can use to build your own API with (Screenshots)
AdmiralAlkex Posted November 10, 2015 Posted November 10, 2015 Is this project still being developed? Considering the multiple years with no updates I think it's safe to assume no. Notice how the OP doesn't even have the latest version?Of course, if anybody wanted to continue it, the source code is still around. trancexx 1 .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
tarretarretarre Posted November 18, 2015 Posted November 18, 2015 (edited) Hmm, im having trouble iterating through an unkown size object, for in dosent seem to work so good, is a linked list the only way to go here? Edit: stupid me, i didnt have anything to enumerate through... I used TicTacToes Linkedlist for ez use Edited November 18, 2015 by tarretarretarre Socket-IO - An event-driven TCP UDF (Realtime chat example) AutoIt-API-WS - An expressive HTTP server you can use to build your own API with (Screenshots)
doudou Posted March 27, 2016 Posted March 27, 2016 _AutoItObject_Startup() crashes immediatly executed under Autoit3_x64.exe (not under Autoit3.exe) with c0000005 (access violation): #include <AutoItObject.au3> _AutoItObject_Startup() Sleep(2000) _AutoItObject_Shutdown() Environment: OS: Win 10, 64 bit AutoIt: 3.3.14.2 AutoItObject: 1.2.8.2 UDFS & Apps: Spoiler DDEML.au3 - DDE Client + ServerLocalization.au3 - localize your scriptsTLI.au3 - type information on COM objects (TLBINF emulation)TLBAutoEnum.au3 - auto-import of COM constants (enums)AU3Automation - export AU3 scripts via COM interfacesTypeLibInspector - OleView was yesterday Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCE
pedrit0 Posted May 7, 2016 Posted May 7, 2016 (edited) As this UDF no longer lives, there is a recent initiative from Minxomat to implement advanced OOP in AutoIT. Edited May 7, 2016 by pedrit0 format Pedrit0, calme et tranquille, la tete dans les nuages et la b*** dans le champagne.
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