Jump to content

Search the Community

Showing results for tags 'autoitobject'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office


  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Member Title




Found 13 results

  1. Hi there, while I created an example script to generate and execute a function during runtime, I stumbled across a neat way to share data between running autoit scripts. This is done using the amazing magic of AutoItObject_Internal . (You'll need at least Version 3.0.0 of AutoItObject_Internal) Using this UDF, you can create a shared data storage, basically an empty "AutoitObject_Internal-"Object which you can then use to write / read data Inline. no set/get methods, just #include "AutoItSharedData.au3" $oShare = _AutoIt_SharedData_CreateOrAttach("MyCustomID") $oShare.some_data = 'foo' and you're done. any other script accessing this data will have to do: #include "AutoItSharedData.au3" $oShare = _AutoIt_SharedData_CreateOrAttach("MyCustomID") ConsoleWrite($oShare.some_data & @LF) Basically it's Larsj's Implementing IRunningObjectTable Interface, but you dont have a Dictionary, but an IDIspatch Object instead. There are already a bunch of IPC options available - and this is another one. AutoItSharedData.au3 Example Script 1 Example Script 2 Output: To test: run Example Script 1, Then run example Script 2.. or the other way around. Example Script 3 Example_sharedata3.au3 Example_sharedata3_Controlsend.au3 Example_sharedata3_Tooltip.au3 To test: run Example_sharedata3.au3. Output: Example SharedData4: Output: /Edit: Please note that there's a limitation with the Running object table : The Script accessing a variable first, will be the "server" for this variable. This means, access to that variable from other scripts should only be possible, as long the "server" script is running! Use appropriate Object Error handlers in case you don't want the surviving "clients" to crash. Feedback and/or improvements appreciated changelog version 2.0 Removed need for AutoItObject, as AutoItObject_Internal now comes with ROT support Added UDF Header Fixed typo on "#include AutoItObjectInternal.au3" -> "#include AutoItObject_Internal.au3" Added ObjGet() after registering the object fails (in case 2 programs tried to register the same ID simultaneously) Updated Examples & zip archive. Cheers, AutoItSharedData.zip
  2. 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)');"& _ "}"& _ "})()")
  3. 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
  4. 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
  5. Hi everybody! Here is my new super tool! It's an AutoItObject TCP Class! Very simple to use, with example and complet decumentation (Made with NaturalDocs) There are two classes: Client, and Server. - The data are encrypted! - The server can handle multiple clients - Data buffering, if you send a big amount of data, it will received as it was sent, not as many little parts of it - OOP programing! (very simple!) PS: You don't need to download AutoItObject, everything you need is in the zip. Update: 03/11/2011 +: Added, -: Deleted/Deprecated, *: Modified, !: Bug corrected === 1.1c === (30/10/2011) Server: +: ClientGetBufferLen method +: Completed doc of ClientPropertyGet and ClientPropertySet methods (Return values) *: Now, when calling .Shutdown, the Callback_LostClient is called for each client. !: Corrected bug: Script error when calling .DisconnectAll befor calling at least one time .Startup (Main socket array was not dimensioned)UDF_TCPClass.rar
  6. 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?
  7. 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
  8. 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?
  9. Using AutoItObject, I cannot make a method with the name 'E3'. The even more bizarre part is when I post the autoit code to this forum, the 'E3' is highlighted in red. See below. #include <AutoItObject.au3> OnAutoItExitRegister("EvtScriptExit") _AutoItObject_StartUp() Global $o=_AutoItObject_Create() ;BUG: Cannot seem to make a property-type method called E3, other names work however MsgBox(0,'VarGetType($o)',VarGetType($o));checkit ;Change this to false to show the bug Global $make_it_work=True ;#cs If Not $make_it_work Then ;Make an E3 property and backer _AutoItObject_AddProperty($o,'_E3',$ELSCOPE_PUBLIC,'initialized') _AutoItObject_AddMethod($o,'E3','E3_property',False) Else ;Make an F3 property and backer _AutoItObject_AddProperty($o,'_E3',$ELSCOPE_PUBLIC,'initialized') _AutoItObject_AddMethod($o,'F3','E3_property',False); THIS LINE DIFFERS IN NAME ONLY 'F3' EndIf If Not $make_it_work Then MsgBox(0,'$o.E3',$o.E3); ERROR Error in expression at $o.E3 Else MsgBox(0,'$o.F3',$o.F3); Not a problem EndIf Func E3_property($me,$value=-1) If @NumParams==2 Then $me._E3=$value Else Return $me._E3 EndIf EndFunc Func EvtScriptExit() _AutoItObject_Shutdown() EndFunc Look at the E3 MsgBox line. So what is E3? Is there a ghost in the machine? I must admit, this is a bit freaky man.
  10. I want to assign to an AutoItObject property without hardcoding the property name. In Javascript it would look like: obj['propertyName']=103; I can read access a property using Execute: Global $ppt_val=Execute('$obj.propertyName') But I cannot assign with: Assign('obj.propertyName',103,4); doesnt work, nor... Assign('$obj.propertyName',103,4) Maybe AutoItObjects have a sooper-secret $obj.__set($name,$val) function? I am looking for a workaround no matter how convoluted. Was thinking about maybe this might be feasible with a JScript COM helper, since I have built a AutoItObject ClassFactory anyhow. I would be able to create dynamic helper functions in JScript COM, that would stop me from writing: Func Set__WinStyle($me,$name,$bool) If False Then ElseIf $name=='Border' Then $me.Border=$bool ElseIf $name=='Popup' Then $me.Popup=$bool ElseIf $name=='Caption' Then $me.Caption=$bool ;etc,etc,etc JScript COM: '?do=embed' frameborder='0' data-embedContent>>
  11. Hi, I made an AutoIt offline web server, inspired by TiddlyWiki personal web notebook. Offline because its purpose is serving locally so we can write local files via any web browser. Just like what TiddlySaver do but without irritating security warning and no cross-domain xhr limitation. Unlike web server around it so simple (no setup), portable, works in limited-user account and integrate itself to windows explorer. It was started to simply make local pages writable (the reason I made UDF ) but then grow to (optionally) provide settings for more advanced usage i.e. enable CGI support, mapping paths, etc. So it now also can be used, for example, as PHP test environment. It supposed to be driven by internal AuJS active page (not completed yet) but these are the preview: serving phpinfo() with SQLite support: the SQLite test page (from XAMPP ) can be found in download. running CKFinder: running AjaXplorer: and php encode explorer (current directory lister, until AuJS is ready) : Basically it can work with any CGI executable I believe it can use AuCGI too. Wouldn't it be nice to have LocalHOTs and AuCGI works together as both made by AutoIt But because I still have to make AuJS can handle multipart POST data and add FLV streaming support I would be very grateful if someone willing to play with this beta and provide AuCGI samples to be packed with the release version. To run the server, execute LocalHOTs.au3 in sourcedebug folder. Once the server run, "Open with LocalHOTs" context menu on windows explorer will be available for *.htm, *.html and *.php (yes you can add *.au3 too, just follow instruction at the console). The code itself only weighted 355KB but the download bloated into 5Megs because I include PHP5 executable (required by current directory listing script) for your convenience. The tests folder contains some pages for you to start play with. Other file that may be useful is Test.all.au3, it will run test unit for both AuJS and JScriptObject UDF. It supposed to be all passed, but if you see any reds (failed test) please report it here. Update: Added FLV & MP4 HTTP Pseudostreaming Eventhough the file is served locally, web player can't jump into time that have not been buffered yet by the player. Streaming enable to seek in the timeline to any positions. Requirements: FLV Streaming - flv streaming is out of the box feature, but to prepare flv files ready for streaming you will need flvmeta, download here (win32/64). This tool will inject keyframes metadata into flv files so web player can use pseudostreaming. Just put flvmeta.exe in script folder, it will check and update flv files when necessary. MP4 Streaming - mp4 streaming depends on ffmpeg, download windows build (32/64) here. Put ffmpeg.exe file in the script folder Samples: tests/Streaming/flowplayer/example/readme.(flv|mp4).html tests/Streaming/JWPlayer/readme.(flv|mp4).html Note: copy any flv and mp4 file into tests/Streaming/media/ folder and rename it to movie.flv and movie.mp4. These files will be used by both flowplayer and JWPlayer samples. Downloads LocalHOTs beta and LocalHOTs_beta.update.rar *** UPDATE *** done: AuJS (ASP like page renderer) for *.aujdropped dir listing, popping explorer insteadlive flv stream (from any movie format), no disk cache.
  12. 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.
  13. I am restructuring Jos' SciTEConfig to allow more control over SciTE. I would greatly appreciate if you would run it on your machine and tell me if it presents an accurate picture of your current SciTE configuration, please. This is not intended to replace the current SciTEConfig. This is just an alternative for those of us that want more control. This script will now perform the following duties: 1. Load a new theme. 2. Change the default action of scripts, I.E., change from edit to run. 3. Enable and disable tools from the Tools menu. 4. Change the loaded definitions from production to beta. 5. Enable and disable the context menu entries. 6. A live preview for on the fly tweaking! Note: For most of these items, the script must be compiled. Note: If you decide to change any of the 'Context Menu' items then be sure to back up your current registry!!!!!!!!!!!!!!!!!!!! Note: Back up your au3.properties too. Note: Works best with the latest AutoIt3 beta version (3.3.9). Also, works best with Jos' latest SciTE4AutoIt3 betas. Enjoy! SciTE Customizer previous: 15|5|4|0|21|0|10|5|9|11|6
  • Create New...