genius257

AutoItObject Pure AutoIt

3 posts in this topic

#1 ·  Posted (edited)

I've made a library, based on AutoItObject UDF with the goal of implementing getter and setter functionality and make it possible to define new object properties in as few steps as possible.

Thank you to @trancexx for getting me on the right track, and all users in Hooking into the IDispatch interface for the code to get me going.

If I've forgotten to add credit, please let me know :)

Things to be added

  • Garbage collection
  • Method support
  • Support for more/all AutoIt variable-types

Example:

#include <AutoItObject_Internal.au3>

$oIDispatch = IDispatch()

$__getter = DllCallbackRegister(CustomGetter, "long", "IDispatch;IDispatch")
$__setter = DllCallbackRegister(CustomSetter, "long", "IDispatch;IDispatch")
$oIDispatch.__defineGetter("a", $__getter)
$oIDispatch.__defineSetter("a", $__setter)

$oIDispatch.a = "start"
MsgBox(0, "", $oIDispatch.a)
$oIDispatch.a = "end"
MsgBox(0, "", $oIDispatch.a)

$oIDispatch.b = 3.14
$oIDispatch.b += $oIDispatch.b
MsgBox(0, "", $oIDispatch.b)

Func CustomGetter($oIDispatch, $oIDispatch2);(return.value, this.value)
    $oIDispatch.a = "_" & $oIDispatch2.a & "_"
EndFunc

Func CustomSetter($oIDispatch, $oIDispatch2);(this.value, caller.value)
    $oIDispatch.a &= $oIDispatch2.a
EndFunc

 

 

AutoItObject_Internal.au3

Edited by genius257
2 people like this

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

This seems something very interesting.... and even more when support for adding methods will be ready.
...worth stay tuned.... :)
Thanks for sharing.

p.s.
this line in AutoItObject_Internal.au3 raises an error:

If $iID==-1 Then Return Return $DISP_E_UNKNOWNNAME

 

Edited by Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites
7 hours ago, Chimp said:

This seems something very interesting.... and even more when support for adding methods will be ready.
...worth stay tuned.... :)
Thanks for sharing.

p.s.
this line in AutoItObject_Internal.au3 raises an error:

If $iID==-1 Then Return Return $DISP_E_UNKNOWNNAME

 

Glad you like it ;)

Sorry about the error. My SciTE did not warn me, but after installing "SciTE4AutoIt3.exe" i now see what you mean ^^

I'll fix and re-upload immediately

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

  • Similar Content

    • harvester2001
      Variable must be of type "Object" inside loop
      By harvester2001
      Hi
      I need help, I found script to check computer model. I want use it in loop to chceck multiple pc`s (targets.txt with computer names).
      But when i try use inside loop i get error: Variable must be of type "Object" and I dont know how to fix this
      Plz help
       
      Local $targets = @ScriptDir& "\targets.txt" Local $log_name = "\scan.log" $msgBox = MsgBox(4, "Scan", "need tergets.txt") Example() Func Example() If $msgBox = 7 Then exit EndIf If Not FileExists($targets) Then MsgBox($MB_SYSTEMMODAL, "", "File: targets.txt - no exist !") Exit EndIf FileOpen($targets, 0) Global $arr[1000] ReDim $arr[_FileCountLines($targets)+1] For $i = 1 to _FileCountLines($targets) $line = FileReadLine($targets, $i) $arr[$i] = $line ; chceck if pc is online Local $iPing = Ping($arr[$i], 250) If $iPing Then ; ONLINE Local $strComputer = $arr[$i] $colItems = "" $Output="" $Output = $Output & "Computer: " & $strComputer & @CRLF $Output = $Output & "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", _ "0x10" + "0x20") If IsObj($colItems) then For $objItem In $colItems $Output = $Output & "Vendor: " & $objItem.Vendor & @CRLF $Output = $Output & "SN: " & $objItem.IdentifyingNumber & @CRLF $Output = $Output & "Name: " & $objItem.Name & @CRLF $Output = $Output & "UUID: " & $objItem.UUID & @CRLF if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop $Output="" Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_ComputerSystemProduct" ) Endif Else ;OFFLINE _FileWriteLog(@ScriptDir & $log_name, $arr[$i]&" OFFLINE") EndIf Next EndFunc  
       
    • Leo1906
      how to properly delete embedded iexplore object
      By Leo1906
      I have a problem here. I have a Script wich opens a Gui with an iExplore Object embedded. The GuiCreate is in an external Function an called in the main while of the script.
      When the Gui closes the Gui gets destoyed. But unfortunately the iExplore Obejct still remains. You can see this by the RAM usage of the exe. After opening a Website the RAM usage stays at  ~ 50 Mb RAM (depending on the website).
      I want it to fall back to the normal state (around 4 MB).
      You can see my attempts to delete the object properly. According to the help an embedded object should get deleted when the GUI gets deleted ...?
       
      GUICreate("Display", 600, 360, -1, -1) Local $oIE = _IECreateEmbedded() $obj = GUICtrlCreateObj($oIE, 0, 0, 600, 360) GUICtrlSetColor(-1, 0xff0000) _IEPropertySet($oIE, "addressbar", False) _IEPropertySet($oIE, "menubar", False) _IEPropertySet($oIE, "statusbar", False) _IEPropertySet($oIE, "toolbar", False) _IEPropertySet($oIE, "resizable", False) _IENavigate($oIE, $dest&"\index.html") GUISetState(@SW_SHOW) While 1 Local $iMsg = GUIGetMsg() Local $tmsg = TrayGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE ;~ $obj = 0 ;~ _WinAPI_DeleteObject ( $obj ) ;~ _IEQuit($obj) ;~ _MemGlobalFree($obj) ;~ $oIE = 0 ;~ _WinAPI_DeleteObject ( $oIE ) ;~ _IEQuit($oIE) ;~ _MemGlobalFree($oIE) GUIDelete() Case $tmsg = $exit _exit() EndSelect WEnd  
      I would be very happy for your help  
      Kind regards
    • Hasoth
      pop-ups using embeded Obj in GUI blocks script from working (onbeforeunload IE)
      By Hasoth
      Hi,
      I've encountered a problem while I tried to close popup in application that is using embeded GUI object. If site has function "onbeforeunload" asking if you really want to exit you will get a popup. In embeded gui object it completly freezes functions and I can't click/close/do anything. I've created sample code with microsoft function example and in external window. Any idea how to close popup in GUI embeded IE? I've tried navigating using _IENavigate($oIE, $sURL, 0) or  changing focus _IEaction($oIE,"focus") but nothing works.
      #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <IE.au3> HotKeySet("{F1}", "myExit") ;GUI setup $GUI_main = GUICreate("Menu", 800, 800, -1, -1) Global $oIE =_IECreateEmbedded() $ObjectIE = GUICtrlCreateObj($oIE, 0, 30, 800, 770) $cButton1 = GUICtrlCreateButton("Start test inside GUI window", 0, 0, 400, 30) $cButton2 = GUICtrlCreateButton("Start test outside GUI window", 400, 0, 400, 30) GUISetState(@SW_SHOW, $GUI_main) ;GUI While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_main Case $ObjectIE Case $cButton1 fTestFunction1() Case $cButton2 fTestFunction2() EndSwitch WEnd ;function inside GUI Func fTestFunction1() Local $sURL = "http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/onbeforeunload.htm" $oIE.Navigate($sURL) _IELoadWait($oIE) $oIE.Navigate("https://www.google.com") MsgBox($MB_TOPMOST, "", "should appear while question box opened", 2) Sleep(2500) Send("!o") EndFunc ;function outside GUI Func fTestFunction2() Local $sURL = "http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/onbeforeunload.htm" $oSecondIE = _IECreate ($sURL) _IELoadWait($oSecondIE) $oSecondIE.Navigate("https://www.google.com") MsgBox($MB_TOPMOST, "", "should appear while question box opened", 2) Sleep(2500) Send("!o") EndFunc ;shortcut to exit Func myExit() GUIDelete($GUI_main) Exit EndFunc  
    • Reizvoller
      _Excel_RangeReadEx Object Error
      By Reizvoller
      Greetings!
      So I have been enjoying leveraging the Excel UDF but have run into a little trouble with the _Excel_RangeReadEx function.
      I am getting an error that says this : 
      I then found this ( https://www.autoitscript.com/forum/topic/169779-excel-range-find-function-giving-bad-results/#comment-1240352 )
      And gave his "Slightly modified" version of the script a go with the same error except the UDF was excel2 as I couldn't over-write the original.
      The function that leverages this is as follows :
      Func rangeFinder () $inputDist = GUIctrlRead ($dispDist) Local $finderKeeper001 = _Excel_RangeFindEx ($oWorkbook, $inputDist) ConsoleWrite ($finderKeeper001[1]) EndFunc The other functions within the same ( entire ) script function well so it's just this that's giving me issues.
      In summary I am just looking for the script to locate the cell(s) that contain that value and return it's location so I can then further process things in my little world
      Thanks for your time!
    • Trolleule
      Object Item not exists, how to catch error?
      By Trolleule
      Hi,
      when i try to access an object item, i get an error, but don't know how to catch this error:
       
      Func GetFirewallRule($sName)     Local $oPolicy = ObjCreate("HNetCfg.FwPolicy2")     MsgBox(0, "test", $oPolicy.Rules.Item($sName)) ; throws error: The requested action with this object has failed. EndFunc Thanks in advance