Sign in to follow this  
Followers 0
SirJohann

[?] AutoItObject Question

1 post in this topic

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?


Codes codes codes.

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
    • 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
       
    • MarkRobbins
      By MarkRobbins
      I've been thinking about this for the last couple of weeks, and I've finally got around to putting together a proof of concept.
      As far as OOP goes, Javascript is a pretty damn good language -- very flexible, but lets look at some code. Here is a two button form for AutoIt written in Javascript.
      var $=this; var hgui; this.MsgHandler_=function (m){ if (m==$.AutoIt.GUI_EVENT_CLOSE) { $.AutoIt.GUIDelete(hgui); return true; }else if (m==button1) { $.AutoIt.Run("notepad.exe"); }else if (m==button2) { alert('Thanks from a javascript alert box!'); } return false; } var button1,button2; function Example1(){ var msg; hgui=$.AutoIt.GUICreate("My Gui",400,500); button1=$.AutoIt.GUICreateButton("Run Notepad",10,10,200,30); button2=$.AutoIt.GUICreateButton("Press Me",10,40,200,30); $.AutoIt.GUISetState($.AutoIt.SW_SHOW,hgui); } Example1(); This code would reside in an external file and be called by AutoIt.
      I've created a framework in AutoIt using AutoItObject that is just big enough to make this code work.
      Basically I am creating an AutoItObject, tacking on some core AutoIt functions and constants, and sending it off to play in Javascript land. There is much more to be tacked on.
      Other than this AutoItObject being a proxy for AutoIt functionality, there is a Javascript COM object into which the javascript file is loaded, and a message loop that calls back into the javascript.
      The framework is 300 lines of code.
      Before I extend this, I want to know if AutoIt ALREADY has a COM object I that I can use like this. But I am thinking that even if it does, this hand-coded way would be better because you can make the calls pass objects instead of parameters.
      Here is the framework:
      #include <AutoItObject.au3> #include <GUIConstants.au3> Global $thisfile=@ScriptFullPath; Global $logg=$thisfile&".log.txt"; Global $jsfile=$thisfile&".js"; ;e C:\batch\borg\TestJsaio.au3.js ;fret not, you do not need, will be a no-op if not exist Global Const $snarl="C:\batch\Snarl_CMD.exe"; ; need script exit for AIO shutdown OnAutoItExitRegister("EvtScriptExit") _AutoItObject_StartUp() ; error handler Global $oError $oError = ObjEvent("AutoIt.Error", "_ErrFunc") ; JScript Com globals Global $_ComObj_proxy Global $_com Global $_Js JScriptInit() ;;;;;;;;;;;;;;;;;;;;;;;;;;done inits ;;;;;;;;;;; begin framework ; set up a mini framework of AutoIt Functions/constants and stick them on an object Global $AutoItForCom=_AutoItObject_Create(); ;_AutoItObject_AddMethod(ByRef $oObject, $sName, $sAutoItFunc, $fPrivate = False) _AutoItObject_AddMethod($AutoItForCom,"GUICreate","GUICreate_AI") _AutoItObject_AddMethod($AutoItForCom,"GUISetState","GUISetState_AI") _AutoItObject_AddMethod($AutoItForCom,"GUIGetMsg","GUIGetMsg_AI") _AutoItObject_AddMethod($AutoItForCom,"GUIDelete","GUIDelete_AI") _AutoItObject_AddMethod($AutoItForCom,"MsgBox","MsgBox_AI") _AutoItObject_AddMethod($AutoItForCom,"GuiCreateButton","GuiCreateButton_AI") _AutoItObject_AddMethod($AutoItForCom,"Run","Run_AI") ;_AutoItObject_AddProperty(ByRef $oObject, $sName, $iFlags = $ELSCOPE_PUBLIC, $vData = "") _AutoItObject_AddProperty($AutoItForCom, "SW_SHOW", $ELSCOPE_PUBLIC+$ELSCOPE_READONLY, @SW_SHOW) _AutoItObject_AddProperty($AutoItForCom, "GUI_EVENT_CLOSE", $ELSCOPE_PUBLIC+$ELSCOPE_READONLY, $GUI_EVENT_CLOSE) ;;; here are the tie-ins that the object will call Func GUICreate_AI($me,$title,$width,$height) #forceref $me ;GUICreate ( "title" [, width [, height [, left [, top [, style [, exStyle [, parent]]]]]]] ) Local $rv=GUICreate($title,$width,$height) Return $rv EndFunc Func GUISetState_AI($me,$flag,$hwnd) #forceref $me ;GUISetState ( [flag [, winhandle]] ) Local $rv=GUISetState($flag,HWnd($hwnd));need to covert Int32 Return $rv EndFunc Func GUIGetMsg_AI($me,$advanced) #forceref $me Local $rv= GUIGetMsg ($advanced) Return $rv EndFunc Func GUIDelete_AI($me,$winhandle) #forceref $me Local $rv=GUIDelete($winhandle) Return $rv EndFunc Func MsgBox_AI($me,$flag,$title,$text) #forceref $me ;MsgBox ( flag, "title", "text" [, timeout [, hwnd]] ) Local $rv=MsgBox($flag,$title,$text) Return $rv EndFunc Func GUICreateButton_AI($me,$text,$left,$top,$width=Default,$height=Default,$style=Default,$exstyle=Default) #forceref $me ;GUICtrlCreateButton ( "text", left, top [, width [, height [, style [, exStyle]]]] ) Local $rv=GUICtrlCreateButton ( $text, $left, $top, $width, $height, $style, $exstyle) Return $rv EndFunc Func Run_AI($me,$program,$wkdir=Default,$show_flag=Default,$opt_flag=Default) #forceref $me ;Msg2("run",$program) Local $rv; If False Then ElseIf @NumParams==2 Then $rv=Run($program) ElseIf @NumParams==3 Then $rv=Run($program,$wkdir) ElseIf @NumParams==4 Then $rv=Run($program,$wkdir,$show_flag) ElseIf @NumParams==5 Then $rv=Run($program,$wkdir,$show_flag,$opt_flag) EndIf ;Run ( "program" [, "workingdir" [, show_flag [, opt_flag]]] ) ;Local $rv=Run($program,$wkdir,$show_flag,$opt_flag) Return $rv EndFunc ;;;;;;;;;;;;;;;; end of tie-ins ;;;;;;;;;; setup JScript COM obj Global $jso=NewComObj() ; import our AutoIt Proxy into the jso $jso.set("AutoIt", $AutoItForCom) ; read our javascript file Global $ftext=FileRead($jsfile) ; set the file text up as a Main function $jso.set_function("Main", "", $ftext) ; need to run our message loop in autoit code, but pass it back to JS land here $jso.set_function("MsgHandler", "m", "return eval('this.MsgHandler_(m)');") ; hold on to your britches... ; this call will run through the js file and the file must do a setup and have a callback MsgHandler_ $jso.Main() ;; Message Loop Local $end_if_true Local $m While True $m=GUIGetMsg(0) $end_if_true=$jso.MsgHandler($m) ;Msg($end_if_true); If $end_if_true Then ExitLoop EndIf WEnd Exit ;; the only thing worth looking at below this point is the _ComObj_init and friends ;;;;;;;;;;;;;;;functions Func EvtScriptExit() ;Msg("EvtScriptExit") _AutoItObject_Shutdown() ;_logline('EvtScriptExit') ;If IsObj($MidiMgr) Then ; $MidiMgr.Terminate() ;EndIf EndFunc Func Msg($s) MsgBox(0,$thisfile,$s) EndFunc Func Msg2($t,$s) MsgBox(0,$t,$s) EndFunc Func logclear() FileDelete($logg) EndFunc Func _logline($line) logline($line) EndFunc Func logline($line) Local $fh1=FileOpen($logg,1); If $fh1<>-1 Then FileWriteLine($fh1,$line) FileClose($fh1) EndIf EndFunc Func logsnarl($line) logerr($line) snarl(10,'Fatal Error',$line) EndFunc Func snarl($i,$t,$s) If Not FileExists($snarl) Then Return EndIf $s1=StringReplace($s,'"',"'") $t1=StringReplace($t,'"',"'") $cmd=$snarl&' snShowMessage '&$i&' "'&$t1&'" "'&$s1&'"'; Run($cmd) EndFunc ;;;;js utils ; #FUNCTION# ================================================================== ; Name : _ComObj_init ; Description : Creates MS Windows Script control and deploy it as proxy for ; AutoIt COM object binding. ; Syntax : _ComObj_init([$VBScriptSupport = false]) ; Parameter : $VBScriptSupport ; By default JScript doesn't have alert() function, it is provided ; by browser's window object. ; We can emulate this using VBScript's MsgBox function, which is ; performance hog because we need another ScriptControl instance. ; Other advantage is to be able to execute other VBScript's methods ; within function via vb.Eval() method. ; This feature is disabled by default. ; ============================================================================= Func _ComObj_init ($VBScriptSupport = false) Local $_Script $_Script = ObjCreate("ScriptControl") $_Script.Language = "JScript" $_Script.Timeout = 60000 ;$_Script.AddCode("var $=this,arrays=[],vb;function set_vbscript($) {vb=$;vb.Language='VBScript';vb.AllowUI=true;}function alert(s){if(vb)vb.Eval('MsgBox(Unescape(""'+s+'""), 0, ""Autoit"")')}function get_proxy(){return $}function new_object($){$=new Function('return{'+$+'}')();$.set=function(k, v){$[k]=v};$.unset=function(k){delete $[k]};$.set_object=function(k,$){this.set(k,new_object($))};$.set_array=function(){var v=[];for(var i=0;i<arguments.length;i++)v[i]=arguments[i];$.set(v.shift(),new_array.apply(this,v))};$.set_function=function(k,p,$){this.set(k,new_function(p,$))};return $}function new_array(){var v=[];for(var i=0;i<arguments.length;i++)v[i]=arguments[i];return v}function array_get($,k){return $[k]}function array_set($,k,v){return $[k]=v}var new_function=(function(){function F(r) {return Function.apply(this,r)}F.prototype = Function.prototype;return function(p,$){p=p.split(/\s*,\s*/);p.push($);return new F(p)}})()") ;a[a.length]=i; ;function new_array(){var v=[];for(var i=0;i<arguments.length;i++)v[i]=arguments[i];return v} Local $more= _ "$.get=function(k){return $[k]};" & _ "$.has=function(n){" & _ " for (var i in this){" & _ " if (i!=n){" & _ " continue;" & _ " }" & _ " if (!this.hasOwnProperty(i)){" & _ " continue;" & _ " }" & _ " if (typeof(this[i])=='function'){" & _ " continue;" & _ " }" & _ " return true;" & _ " };" & _ " return false;" & _ "};" & _ "$.keys=function(){" & _ " var a=[];" & _ " for (var i in this){" & _ " if (this.hasOwnProperty(i)){" & _ " if (typeof(this[i])!='function'){" & _ " a[a.length]=i;" & _ " }" & _ " }" & _ " };" & _ " return a;" & _ "};" & _ "$.set2=function(){" & _ " for(var x=0;x<arguments.length-1;x+=2){" & _ " this[arguments[x]]=arguments[x+1]" & _ " }" & _ "};" & _ "Array.prototype.item=function(n){" & _ " return this[n];" & _ "};" & _ "Array.prototype.has=function(v){" & _ " for(x=0;x<this.length;x++){" & _ " if(this[x]==v){return true;}" & _ " }" & _ " return false;" & _ "};" & _ "Array.prototype.asString=function(d){" & _ " var s='';" & _ " for(x=0;x<this.length;x++){" & _ " if(s==''){s=this[x];}else{s+=d+this[x];}" & _ " }" & _ " return s;" & _ "};" $_Script.AddCode("var $=this,arrays=[],vb;function set_vbscript($) {vb=$;vb.Language='VBScript';vb.AllowUI=true;}function alert(s){if(vb)vb.Eval('MsgBox(Unescape(""'+s+'""), 0, ""Autoit"")')}function get_proxy(){return $}function new_object($){$=new Function('return{'+$+'}')();$.set=function(k, v){$[k]=v};"&$more&"$.unset=function(k){delete $[k]};$.set_object=function(k,$){this.set(k,new_object($))};$.set_array=function(){var v=[];for(var i=0;i<arguments.length;i++)v[i]=arguments[i];$.set(v.shift(),new_array.apply(this,v))};$.set_function=function(k,p,$){this.set(k,new_function(p,$))};return $}function new_array(){var v=[];for(var i=0;i<arguments.length;i++)v[i]=arguments[i];return v}function array_get($,k){return $[k]}function array_set($,k,v){return $[k]=v}var new_function=(function(){function F(r) {return Function.apply(this,r)}F.prototype = Function.prototype;return function(p,$){p=p.split(/\s*,\s*/);p.push($);return new F(p)}})()") If $VBScriptSupport = true Then $_Script.Run("set_vbscript", ObjCreate("ScriptControl")) Return $_Script EndFunc ; ============================================================================= Func NewComObj() Local $com While True $com=$_com.new_object("") Sleep(30) If IsObj($com) Then ExitLoop EndIf WEnd Sleep(30) Return $com EndFunc Func JScriptInit() $_ComObj_proxy = _ComObj_init(true) $_com = $_ComObj_proxy.Run("get_proxy") $_Js = $_com.new_object("") $_Js.set_function("AIOSetProperty","o,n,v","o[n]=v;") EndFunc Func JS_SetProp() $_Js = $_com.new_object("") $_Js.set_function("AIOSetProperty","o,n,v","o[n]=v;") Return $_Js; EndFunc My main questions are...
      Why doesn't this already exist, and where is it? and... Why doesn't this already exist -- what wall am I headed for?