tarretarretarre

TeenyScript *@ v2.1.3* - A new way of programming in AutoIt with objects and much more

25 posts in this topic




Good work tarre³

I really need to start to learn the basics of oop. :)

 

1 person likes this

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
6 hours ago, UEZ said:

Good work tarre³

I really need to start to learn the basics of oop. :)

 


Thanks, im glad you like it, hopefully this will give you an idea how it works, if you have any questions I am more than happy to help you.


 

@newpost_ The script is now updated to "beta 2".  

  • Now its possible to include other .ts files (example in new zip file)
  • I also removed the compiled binaries since AutoitObject compiles them automatically upon running
  • everything after the #MAIN tag will only be executed from the file you are starting it from.
  • All .ts.au3 files will be inserted into one file (a bit like au3 Stripper) which means there wont be 2 * your .ts.au3 files in the directories

 

 

Share this post


Link to post
Share on other sites

I have updated the Script with some more features and bugfixes

  • F5 run script (Will delete file after run is complete)
  • F7 (Will store and NOT run file)
  • Better examples included 
  • Namespaces are now avilable (Check documentation)
  • Some bugs fixed with include.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Another update with more features, bugfixes and examples

  • #include now accepts both "x.au3" and "x.ts" instead of just "x.ts", but they will be interpreted differently
  • Added @MethodName macro to get class method \ Function name upon use (See Macros example)
  • Added @MethodParams macro to retrive all params assigned in that method / Function (See Error example)
  • Added __classname__ and __namespace__ READONLY properties to classes which can useful for debugging and other things (See error example)
  • The @Namespace can now be used as a macro to retrive the previous stated @Namespace x
Edited by tarretarretarre

Share this post


Link to post
Share on other sites

I have not played with this yet, but it looks amazing. Will definitely try this sometime, good work! :lmao:

1 person likes this

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

On 2016-07-12 at 10:25 AM, AlmarM said:

I have not played with this yet, but it looks amazing. Will definitely try this sometime, good work! :lmao:

Im happy to hear that, im working on  this as often as I can, because I need this myself

OT: Beta 5 is now here with more stuff!

 

Buggfixes

  • Multiple "@Use x in x" with same name was replaced globally in file, instead of per global class, its now working as intended
  • An vanilla autoit function after an class extension would cause the vanilla function to retrive $this as a parameter, this is no longer an issue
  • More minor buggfixes that I cannot remember

Changes

  • READONLY class property __classname__ is now called __cName__

Additions / New features

  • Design \ Spellchecking
  • Proper Error-reporting is now done when trying to including non existing .ts files or when trying to include a file which already has been included
  • #Incude can now be used to include a whole directory and even include recursively (#include "path\*.ts") for directory only, (#include "path\**.ts") for recursive search. This means you can work more with namespaces and LESS with includes
  • Forward slashes are now accepted when including files, this will make namespacing easier (#include "path/to/file.ts")
  • Added READONLY class property __methods__ which returns an array of ALL the class methods in that class
  • Added READONLY class property __cParams__ which returns the paramteres of your classobject (__params__ is reserved for AutoitObject)

These new features also have examples included

Edited by tarretarretarre

Share this post


Link to post
Share on other sites

Recursive directory Includes is an awesome idea!

 

Ian


My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.

Share this post


Link to post
Share on other sites
On 2016-07-14 at 7:40 AM, llewxam said:

Recursive directory Includes is an awesome idea!

 

Ian

Its almost "autoloading" and yes, i really liked that feature :D

 

Beta 6 is now out with minor stuff 

Buggfixes

  • Minor fixes

Changes

  • #Include "folder/**.ts" will now ignore the BackUp folder because of TidyUp saving backups

Additions / New features

  • Scite TidyUp is now implemented and only accessible via the hotkey (CTRL + T)
  • Php and Javascript like-lists are now available $MyList = {"key": "val"} or $MyList {"key" => "val"} See lists example!

Share this post


Link to post
Share on other sites

Another release with more fixes and solutions to problems

 

Beta 7

Changes

  • Class READONLY property __cParams__ is now replaced with __Properties__ because it made _no sense_ showing the class parameters used by the class itself (In most cases anyway).

Additions / features

  • Relative paths can now be used with regular Au3 Files (TS will check if the file exists in either the Au3 include dir or the relative path (See Includ example))
  • Class properties can now get assigned with EMPTY lists (@Private $this.var = {})
  • Added a more sleek COM error handler which shows you the actual code that caused the Com error and attempts to propose a solution (See image below).
  • Added _TS_ErrorNotify which works similar to _IEErrorNotify

Buggfixes

  • Fixed issue with class properties that had lists, it is now working as intended  example: ($this.list{'newItem'} = 25) (See updated Lists example)

 

FkD0dRq.png

Com errors will be displayed as a Messagebox if the script is compiled

 

/Tarre

Share this post


Link to post
Share on other sites

Hello guys!

So I have been late with updates due to my full time job, spending quality time with my significant and also developing a FULLY featured framework, which is by the way done in TeenyScript and its comming along nicely, I cant wait to explain and show it to you guys!

 

Oh yeah I almost forgot, i am also working on a official website with documentation for TeenyScript

Anyway, here is a small update with 5 new features and some critical bugs resolved.

 

Beta 8

Changes

  • * Hotkeys changed *
  • Use F5 to Run script
  • Use F6 to Build script (.au3)
  • Use F7 to Build script (.exe)
  • Use F8 to change $CmdLine

Additions / features

  • It is now possible to return an array without creating assigning a variable with Dim or Local.Return [1, 2, 3, 4, 5] )
  • Functions can now be created and passed as an argument within TS functions and classes (See Example - Passing functions as parameters)
  • It is now possible to include .ts files from it's relative parent directory #include </parentDir/xxxx.ts>
  • It is now possible to create string templates, similar to PHPS Heredoc. (See Example - EoD)
  • F7 to Build script (.exe) with Aut2Exe (Will get more sofisticated later on!)
  • F8 to change $CmdLine

Buggfixes

  • Comments after a class or function  ( $x = func(); This is a comment ) would cause the regex not to parse the function, this is now resolved
  • Fixed a "Catastrophic backtracking" of lists ($MyList = {"key": "val", "key", "val"}) which is explained here

Share this post


Link to post
Share on other sites

Man this is promising. Really very good!

Can't wait to take a look on the framework!


My stuff

Spoiler

My UDFs  _AuThread multithreading emulation for AutoIt · _ExtInputBox an inputbox with multiple inputs and more features · forceUTF8 fix strings encoding without knowing its original charset · JSONgen JSON generator · _TCPServer UDF multi-client and multi-task (run on background) event-based TCP server easy to do · _TCPClient_UDF multi-server and multi-task (runs on background) event-based TCP client easy to do · ParseURL and ParseStr functions ported from PHP · _CmdLine UDF easily parse command line parameters, keys or flags · AutoPHP Create documents (bills, incomes) from HTML by sending variables/arrays from AutoIt to PHP · (Un)Serialize Convert arrays and data into a storable string (PHP compatible) · RTTL Plays and exports to MP3 Nokia-format monophonic ringtones (for very old cellphones) · I18n library Simple and easy to use localization library · Scripting.Dictionary OOP and OOP-like approach · Buffer/stack limit arrays to N items by removing the last one once the limit is reached · NGBioAPI UDF to work with Nitgen fingerprint readers · Serial/Licensing system require license key based on unique machine ID from your users · HTTP a simple WinHTTP library that allows GET, POST and file uploads · Thread true AutoIt threads (under-dev) · RC4 RC4 encryption compatible with PHP and JS Classes _WKHtmlToX uses wkhtmlto* to convert HTML files and webpages into PDF or images (jpg, bmp, gif, png...) Snippets _Word_DocFindReplaceByLongText replace strings using Word UDF with strings longer than 255 characters (MSWord limit) rangeparser parser for printing-like pages interval (e.g.: "1,2,3-5") EnvParser parse strings/paths with environment variables and get full path Random stuff Super Mario beep sound your ears will hurt

 

Share this post


Link to post
Share on other sites
On 2016-08-07 at 5:05 PM, Jefrey said:

Man this is promising. Really very good!

Can't wait to take a look on the framework!

Thanks man, although the code in this state of TeenyScript is really really really bad and messy, but no worries, I am currently clean-writing the whole project and preparing it for the future.

 

 

 

1 person likes this

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Sorry for all the wait, hopefully it was worth it, because finally, I can release TeenyScript as a finished product

Additions / new features

  • Project added to git https://github.com/tarreislam/teenyscript (This thread will always have the latest version ofc)
  • Created a homepage for documentation and examplecode: http://teenyscript.tarre.nu/documentation
  • Added a more pleasent Options GUI (All features and settings will be handled here).
  • More error checking done by TS when parsing.
  • Com error reporting is more advanced
  • Added new keyword "construct". (See more at http://teenyscript.tarre.nu/documentation#13-Func(Construct)
  • Classes and extension methods can now be assigned with @Private and @Public keywords.  (see more at http://teenyscript.tarre.nu/documentation#3-@Public, @Private, @Readonly)
  • Properties can now have lists and arrays assigned directylty to them (@Private $this.list = {"key" => "value", "key": 1234}, @Private $this.array = [1,2,3,4,5, [1,2,3,4,5]])
  • Scite Calltips & Keywords for TeenyScript can now be installed through the NEW options GUI 
  • Everything written from TeenyScript will be logged under logs/console.log and will only be accesable when TeenyScript is not running, this is for unexpected crashes etc.
  • A sort of "Project" system is now added, which allows you to easily deploy your script with various settings (See F8 -> create new project)

Changes

  • Removed #MAIN and replaced it with #DEBUG. (See more at http://teenyscript.tarre.nu/documentation#20-#DEBUG)
  • Namespaces can no longer be used in #DEBUG (old #MAIN)
  • The __parent__ class property is now @Private instead of @Readonly
  • AutoitObject is now added directly as code to the script, rather than being included with AutoIts regular #include (Removing the step of forcing the user to add the library as an UDF in Scite Options before TeenyScript worked properly)
  •  AutoitObject is only included when actual AutoitObject is used.
  • #Include "/*.ts" previously searched the "execution dir", but now it searches the parent folder instead. #Include "//*.ts" will instead search from the execution folder (See more at http://teenyscript.tarre.nu/documentation#11-#Include)

Buggfixes / misc 

  • Removed a random _Array Udf that i forgot was there

 

Things that i have on the rader, but didnt feel neccesary to implement due to the already delayed RELEASE of TeenyScript

  •  Interfaces
  •  Recursive usage of lists ( {"next_list": {"third_list": {"a": 1}}})


 

Thanks for now /Tarre

Edited by tarretarretarre

Share this post


Link to post
Share on other sites

Nice to know that :D

I am unable to access the docs page (it throws a timeout error). Wouldn't it be possible to use Github Pages, so the community would also be able to help on it? :)

1 person likes this

My stuff

Spoiler

My UDFs  _AuThread multithreading emulation for AutoIt · _ExtInputBox an inputbox with multiple inputs and more features · forceUTF8 fix strings encoding without knowing its original charset · JSONgen JSON generator · _TCPServer UDF multi-client and multi-task (run on background) event-based TCP server easy to do · _TCPClient_UDF multi-server and multi-task (runs on background) event-based TCP client easy to do · ParseURL and ParseStr functions ported from PHP · _CmdLine UDF easily parse command line parameters, keys or flags · AutoPHP Create documents (bills, incomes) from HTML by sending variables/arrays from AutoIt to PHP · (Un)Serialize Convert arrays and data into a storable string (PHP compatible) · RTTL Plays and exports to MP3 Nokia-format monophonic ringtones (for very old cellphones) · I18n library Simple and easy to use localization library · Scripting.Dictionary OOP and OOP-like approach · Buffer/stack limit arrays to N items by removing the last one once the limit is reached · NGBioAPI UDF to work with Nitgen fingerprint readers · Serial/Licensing system require license key based on unique machine ID from your users · HTTP a simple WinHTTP library that allows GET, POST and file uploads · Thread true AutoIt threads (under-dev) · RC4 RC4 encryption compatible with PHP and JS Classes _WKHtmlToX uses wkhtmlto* to convert HTML files and webpages into PDF or images (jpg, bmp, gif, png...) Snippets _Word_DocFindReplaceByLongText replace strings using Word UDF with strings longer than 255 characters (MSWord limit) rangeparser parser for printing-like pages interval (e.g.: "1,2,3-5") EnvParser parse strings/paths with environment variables and get full path Random stuff Super Mario beep sound your ears will hurt

 

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

I can access it now! Perhaps it was some DNS propagating...

What I meant with Github Pages is this: https://pages.github.com/

The advantage on it is that the community can also help on coding the website/docs  :)

Just like this: https://jesobreira.github.io/TeenyScript/

Edit: I can't pull request because I have no pull permission on the repo nor the repo has a "gh-pages" branch. If you find it interesting, just create a branch named "gh-pages" and I send a PR :)

Edited by Jefrey
PR

My stuff

Spoiler

My UDFs  _AuThread multithreading emulation for AutoIt · _ExtInputBox an inputbox with multiple inputs and more features · forceUTF8 fix strings encoding without knowing its original charset · JSONgen JSON generator · _TCPServer UDF multi-client and multi-task (run on background) event-based TCP server easy to do · _TCPClient_UDF multi-server and multi-task (runs on background) event-based TCP client easy to do · ParseURL and ParseStr functions ported from PHP · _CmdLine UDF easily parse command line parameters, keys or flags · AutoPHP Create documents (bills, incomes) from HTML by sending variables/arrays from AutoIt to PHP · (Un)Serialize Convert arrays and data into a storable string (PHP compatible) · RTTL Plays and exports to MP3 Nokia-format monophonic ringtones (for very old cellphones) · I18n library Simple and easy to use localization library · Scripting.Dictionary OOP and OOP-like approach · Buffer/stack limit arrays to N items by removing the last one once the limit is reached · NGBioAPI UDF to work with Nitgen fingerprint readers · Serial/Licensing system require license key based on unique machine ID from your users · HTTP a simple WinHTTP library that allows GET, POST and file uploads · Thread true AutoIt threads (under-dev) · RC4 RC4 encryption compatible with PHP and JS Classes _WKHtmlToX uses wkhtmlto* to convert HTML files and webpages into PDF or images (jpg, bmp, gif, png...) Snippets _Word_DocFindReplaceByLongText replace strings using Word UDF with strings longer than 255 characters (MSWord limit) rangeparser parser for printing-like pages interval (e.g.: "1,2,3-5") EnvParser parse strings/paths with environment variables and get full path Random stuff Super Mario beep sound your ears will hurt

 

Share this post


Link to post
Share on other sites
12 hours ago, argumentum said:
twitter.com##DIV[class="close-modal-background-target"] twitter.com##DIV[id="signup-dialog"][class="SignupDialog modal-container u-textCenter"] twitter.com##DIV[class="modal-overlay"] www.pinterest.com##DIV[class="modalScroller"] www.pinterest.com##DIV[class="UnauthBanner Module"] www.twitch.tv##DIV[id="nav_primary"][class="nav_section js-nav-menu"] www.twitch.tv##DIV[id="nav_streams"][class="nav_section"] www.twitch.tv##DIV[class="js-games games items list-games"] www.twitch.tv##H3[class="title"] www.pinterest.com##DIV[class="modalMask dark"] www.pinterest.com##DIV[class="Module UnauthBanner"] www.helagotland.se##DIV[class="fcol6"] www.aftonbladet.se##IFRAME[id="yui_3_15_0_2_1436035429624_1372"] www.twitch.tv##IMG[class="emoticon tooltip"] @@||www.dingit.tv/$document m.facebook.com##A[class="_19no touchable"][href="/home.php?refid=8"] m.facebook.com##A[class="_19no touchable"][href="/notifications.php?refid=8"] m.facebook.com##A[class="_19no touchable"][href="#"] m.facebook.com##A[class="_19no touchable"][href="/search/?refid=8"] m.facebook.com##A[class="_19no touchable"][href="/friends/center/requests/?refid=8"] m.facebook.com##DIV[id="mJewelNav"][class="_4g33 _52we"] @@||www.tv3play.se/$document @@||www.tv3play.se/$document plex.tarre.nu##DIV[class="alert-bar notify"] www.facebook.com##DIV[id="u_jsonp_71_1a"][class="_4-u2 _4-u8"] www.facebook.com##DIV[class="_4-u2 mbm _5v6e _4-u8"] www.facebook.com##DIV[id="u_jsonp_73_0"][class="_4-u2 _5v6e cardRightCol _4-u8"] www.facebook.com##DIV[id="leftCol"] www.facebook.com##DIV[id="u_jsonp_75_0"][class="_4-u2 _5v6e cardRightCol _4-u8"] www.facebook.com##DIV[class="_4-u2 _5v6e cardRightCol _4-u8"] www.facebook.com##DIV[class="_4-u2 _4-u8"] www.facebook.com##[class="_4-u2 _19ah _2ph_ _4-u8"] www.facebook.com##DIV[class="rhcFooterWrap"] www.facebook.com##SPAN[class="_51lp _51lr _5ugg _5ugh _3-99"] www.facebook.com##SPAN[id="notificationsCountValue"] www.facebook.com##DIV[id="pagelet_timeline_profile_actions"] www.facebook.com##SPAN[id="mercurymessagesCountValue"]

not quite functional

Whops, thats my Adblock settings, the site is http://TeenyScript.tarre.nu/

11 hours ago, Jefrey said:

I can access it now! Perhaps it was some DNS propagating...

What I meant with Github Pages is this: https://pages.github.com/

The advantage on it is that the community can also help on coding the website/docs  :)

Just like this: https://jesobreira.github.io/TeenyScript/

Edit: I can't pull request because I have no pull permission on the repo nor the repo has a "gh-pages" branch. If you find it interesting, just create a branch named "gh-pages" and I send a PR :)

I removed all the countries from my PfSense "top 20 spammer country-list", that might have been the issue.

Ah now i see what you mean with pages, the thing is, I searched for something similar before creating my own sort of documnetation-page, I will create that gh-pages branch and allow pull requests when I come home from work.

I was thinking of expanding my Documentation-page to allow users to use OAuth to login with github at the TeenyScript page and edit pages (like wiki).

 

Btw 1.1.0 is now released

Changes/Additions

  • Changed "Edit project" gui and added some more error-checking and allow the user to utilize more Au2exe options
    Yq94aBy.png

Buggfixes

  • Regex error caused lists to collide if written on the same line: MsgBox(0, $mylist{"abc"} , $mylist{"def"})
  • A class constructor default variables would cause an bool comparision instead of just pass the variable names:
     

 

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

So here we go again with some more crucial updates. 

Buggfixes

  • A minor programming error caused AutoitObject to be included when it was not needed
  • Misc minor stuff

Changes

  • Projects (F8 -> Create new project) will give the user some default templates (More complex templates will be added later) Imgur
  • Code improvements

New features

  • Added a "Autoit keyword enhanchment" on For $x In $y See more here
  • It is now possible to pass arrays in functions call, without declaring them $MyFunc([1, 2, 3, 4, 5])See more here
  • Projects (F8 ->Edit Project Settings) has a new feature for the architecture option 32 & 64 bit calledLauncher, its purpose is pretty simple, the source code should give you a hint Launcher.au3
  • The version control system (VCS) using Semantic Versioning 2.0.0  is now finished and will check the current TeenyScript version against the project and output some warnings and such (if needed)
Edited by tarretarretarre

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

    • minxomat
      By minxomat
      Introduction
      Since the introduction of ObjCreateInterface, AutoIt is able to create native, real objects. However, this is quite difficult for non-experienced users. This UDF here enables a "classic" syntax for declaring classes and instantiating objects from them. Before you ask: No, it is not just another preprocessor that's "faking" OOP syntax - this is the real deal. While it assists users with a more familiar syntax, objects are created at runtime.
      Care has been put into this UDF and it is in the authors interest to fix all bugs remaining and implement features as long as the result works in the Stable release of AutoIt.
      Features
      Define an unlimited number of classes. Create unlimited instances of objects. Create arrays of objects. Mix and match different data types in arrays (one or more elements can be objects). Define custom constructors and destructors. Pass an unlimited number of arguments to the constructor (even to all objects in one array at the same time). Automatic garbage collection. Compatible with Object-enabled AutoIt keywords (With etc.), optional parentheses on parameterless functions. Fully AU3Check enabled. IntelliSense catches class-names for auto-completion. Automatically generates a compilable version of the script. Non-instantated classes get optimzed away. Create C-style macros. Download
      Read the Tutorials - Download - Download (forum mirror)
      Please use the github issue tracker to report bugs or request features. Please read the tutorial before asking a question. Thanks!
    • guinness
      By guinness
      I posted this the other day, but thought I would post in a separate topic instead.
      #include <MsgBoxConstants.au3> ; ---- Start of Person Class ; Stored in the 'object' to verify it's our 'object' and not some random array Global Const $PERSON_GUID = '4197B285-6AB1-489B-8585-08C852E33F3D' ; Friendly names for 0, 1, 2 and 3 Global Enum $PERSON_AGE, $PERSON_NAME, $PERSON_ID, $PERSON_MAX ; Constructor Func Person($sName, $iAge) Local $hPerson[$PERSON_MAX] ; Set the GUID, so as the verification will work $hPerson[$PERSON_ID] = $PERSON_GUID Person_SetAge($hPerson, $iAge) Person_SetName($hPerson, $sName) ; Return the Person 'object' Return $hPerson EndFunc ;==>Person ; Getter for the age property Func Person_GetAge(ByRef $hPerson) Return _Person_IsObject($hPerson) ? $hPerson[$PERSON_AGE] : Null EndFunc ;==>Person_GetAge ; Setter for the age property Func Person_SetAge(ByRef $hPerson, $iAge) ; If not a valid 'object' or integer then return If Not _Person_IsObject($hPerson) Or Not IsInt($iAge) Then Return ; Set the age $hPerson[$PERSON_AGE] = $iAge EndFunc ;==>Person_SetAge ; Getter for the name property Func Person_GetName(ByRef $hPerson) Return _Person_IsObject($hPerson) ? $hPerson[$PERSON_NAME] : Null EndFunc ;==>Person_GetName ; Setter for the name property Func Person_SetName(ByRef $hPerson, $sName) ; If not a valid 'object' then return If Not _Person_IsObject($hPerson) Then Return ; Set the name $hPerson[$PERSON_NAME] = $sName EndFunc ;==>Person_SetName ; ToString() for the 'object' Func Person_ToString(ByRef $hPerson) Return _Person_IsObject($hPerson) ? StringFormat('Name: %s, Age: %i', $hPerson[$PERSON_NAME], $hPerson[$PERSON_AGE]) : Null EndFunc ;==>Person_ToString ; Check if it's a valid 'object' and not some random array. "NTERNAL ONLY! Func _Person_IsObject(ByRef $hPerson) Return UBound($hPerson) = $PERSON_MAX And $hPerson[$PERSON_ID] == $PERSON_GUID EndFunc ;==>_Person_IsObject ; ---- End of Person Class Example() Func Example() ; Store the Person 'object', which is just a glorified array Local $hP1 = Person('John', 30) ; Display the 'object' MsgBox($MB_SYSTEMMODAL, 'Person 1', Person_ToString($hP1)) ; Create a new person ; Store the Person 'object', which is just a glorified array Local $hP2 = Person('James', 36) ; Display the 'object' MsgBox($MB_SYSTEMMODAL, 'Person 2', Person_ToString($hP2)) ; Set the age for Person 2 Person_SetAge($hP2, 45) ; Display the 'object' MsgBox($MB_SYSTEMMODAL, 'Person 2 - Revised', Person_ToString($hP2)) EndFunc ;==>Example  
    • 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?
    • matwachich
      By matwachich
      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