Jump to content

AutoIt Object-Oriented Preprocessor


Kip
 Share

Recommended Posts

Hi,

So..... quite a lot discussions about OO.

At the end of every discussion it's always the same answer: NO.

Too bad, because you can do a lot of nice stuff with objects.

So what if there was some kind of preprocessor that can translate object oriented script to regular AutoIt script? :)

It's far from finished, but the main stuff works.

Example:

$iObject1 = MyObject()
$iObject2 = MyObject()

$iObject1.SetString("Hello, I'm 1");hello


MsgBox(0,"Test",$iObject1.GetString() &@CRLF& $iObject2.GetString())


Obj MyObject()
    
    
    Declare $sMyString[3], $sInt = 1; Comments are possible again;)
    
    
    Func SetString($sString)
        
        $sMyString[0] = $sString
        
    EndFunc
    
    Func GetString()
        
        If $sMyString[0] Then Return $sMyString[0]
        
        Return "$sMyString[0] is empty"
        
    EndFunc
    
EndObj

The messagebox will say:

Hello, I'm 1

Hi, I'm 2

Cool, huh. Even though you created 2 of the same objects, they can hold different data in the same variables. :mellow:

; Use 'Declare' to declare variables in objects. Variables declared using Local and Dim can only be used the first time when the object is created. After that they'll be deleted.

How to install:

1. Download the AutoIt3.exe from the attachments.

2. Go to the Autoit installation folder

3. Rename the orginal AutoIt3.exe to: 'AutoIt3 Original.exe' (Without the qoutes)

4. Rename 'Au3Check.exe' to 'Au3Check2.exe'

5. Create a new script and run it :( (from SciTE or just double-click on the icon)

AutoIt3.exe

Edit: If I wanted to share the source, I would have uploaded it. Since I didn't, I don't want people to decompile it and post the source on the forum.

Edited by Kip
Link to comment
Share on other sites

  • Replies 49
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Gui, you say?

Obj Window($sTitle, $iWidth=-1, $iHeight=-1, $iX=-1, $iY=-1, $iStyle=-1, $iExStyle=-1)
    
    Declare $hWnd
    
    
    Func _OnCreation(); will be called when object is created
        
        $hWnd = GUICreate($sTitle, $iWidth, $iHeight, $iX, $iY, $iStyle, $iExStyle)
        
    EndFunc
    
    Func State($iState=@SW_SHOW)
        
        Return GUISetState($iState)
        
    EndFunc
    
    Func GetVar($sVar)
        
        Return Eval($sVar)
        
    EndFunc
    
EndObj

well, calling a object twice on the same line will cause trouble:

Msgbox(0,"sdds",$iObject1.GetString() &@CRLF& $iObject2.GetString())

And calling Return in a function of a object will cause that 'Declare' variables, edited in that function, wont be saved.

Edited by Kip
Link to comment
Share on other sites

How to install:

1. Download the AutoIt3.exe from the attachments.

2. Go to the Autoit installation folder

3. Rename the orginal AutoIt3.exe to: 'AutoIt3 Orginal.exe' (Without the qoutes)

4. Rename 'Au3Check.exe' to 'Au3Check2.exe'

5. Create a new script and run it :mellow: (from SciTE or just double-click on the icon)

AutoIt3.exe

what's this for ???

anyway... is the whole block of code supposed to be in autoit ??

cause it's not working...

Edited by torels

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

If you copy and rename the files, SciTE automaticly runs my program. When everything is converted, the new Autoit3.exe file automaticly runs the orginal one.

Let's write all steps down, to be clear.

- F5 pressed in SciTE (Run)

- Au3Check.exe doesnt run, because we changed the name. (otherwise it'll create syntax errors)

- My AutoIt3.exe gets called:

- Your OO script gets converted to a normal script

- New script will be saved as __TempScript.au3

- __TempScript.au3 will be executed with 'AutoIt3 Orginal.exe' (I know.. its spelled: original, but its already compiled)

Link to comment
Share on other sites

The whole idea rather cool but what is with the new AutoIt3.exe and why do we need to replace it?

Could you explain that part a little more?

[Edit]

I see you already replied. :mellow:

Edited by mrRevoked
Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Link to comment
Share on other sites

but what is with the new AutoIt3.exe

Objects dont belong in the AutoIt syntax, so it should be converted first.

You don't HAVE to replace it. It's just much easier.

If you dont replace it, you'll have to drop your script onto the AutoIt3.exe from the zip (unzip first), and what you'll get is a new script called __TempScript.au3. That is the script you can run with the normal AutoIt3.exe (in your installation dir)

If you do replace it, you dont have to drag and drop anything. You'll just have to hit Run in SciTE :mellow:

Edited by Kip
Link to comment
Share on other sites

Sure

This was __TempScript.au3 right after created by "new" AutoIt3.exe:

Global $__ObjectOr_ObjectsCount = 1
Global $__ObjectOr_ObjectNames[1]

Global $__ObjectOr_ObjectsCount = 1
Global $__ObjectOr_ObjectNames[1]

MsgBox(0,'','')

$iObject1 = __Obj_MyObject_EndObj()
$iObject2 = __Obj_MyObject_EndObj()

Call("__Obj_"&$__ObjectOr_ObjectNames[$iObject1]&"_EndObj_Func_SetString_EndFunc", $iObject1, "Hello, I'm 1")
Call("__Obj_"&$__ObjectOr_ObjectNames[$iObject2]&"_EndObj_Func_SetString_EndFunc", $iObject2, "Hi, I'm 2")


$sString1 = Call("__Obj_"&$__ObjectOr_ObjectNames[$iObject1]&"_EndObj_Func_GetString_EndFunc", $iObject1)
$sString2 = Call("__Obj_"&$__ObjectOr_ObjectNames[$iObject2]&"_EndObj_Func_GetString_EndFunc", $iObject2)

MsgBox(0,"Test",$sString1 &@CRLF& $sString2)





Func __Obj_MyObject_EndObj_Func_SetString_EndFunc($i_InternalObjectID, $sString)
Local $sMyString; = Eval("__Obj_MyObject_EndObj_Inst_"&$i_InternalObjectID&"_EndInst_Name_sMyString;_EndName")
        
        $sMyString = $sString
        
Assign("__Obj_MyObject_EndObj_Inst_"&$i_InternalObjectID&"_EndInst_Name_sMyString;_EndName",$sMyString;,2)
EndFunc

Func __Obj_MyObject_EndObj_Func_GetString_EndFunc($i_InternalObjectID)
Local $sMyString; = Eval("__Obj_MyObject_EndObj_Inst_"&$i_InternalObjectID&"_EndInst_Name_sMyString;_EndName")
        
        Return $sMyString
        
Assign("__Obj_MyObject_EndObj_Inst_"&$i_InternalObjectID&"_EndInst_Name_sMyString;_EndName",$sMyString;,2)
EndFunc

Func __Obj_MyObject_EndObj()
$__ObjectOr_ObjectsCount += 1
ReDim $__ObjectOr_ObjectNames[$__ObjectOr_ObjectsCount+1]
$__ObjectOr_ObjectNames[$__ObjectOr_ObjectsCount] = "MyObject"
    
    
Assign("__Obj_MyObject_EndObj_Inst_"&$__ObjectOr_ObjectsCount&"_EndInst_Name_sMyString;_EndName","",2)
    
    
    
    
Return $__ObjectOr_ObjectsCount
EndFunc
Link to comment
Share on other sites

You have this twice:

Global $__ObjectOr_ObjectsCount = 1
Global $__ObjectOr_ObjectNames[1]

Global $__ObjectOr_ObjectsCount = 1
Global $__ObjectOr_ObjectNames[1]

And I mean an example of the OO code.

That shouldn't be the problem.

OO is OO froom yoour first poost.

Edited by trancexx
Link to comment
Share on other sites

Without rewriting the engine to take advantage of actual object oriented software benefits, what's the advantage of a syntax change?

I'm not saying this to be snarky, I'm genuinely curious. This looks pretty cool :mellow:

Link to comment
Share on other sites

cool it works..!

after I got rid of the comment (; Use 'Declare' to declare variables in objects. Variables declared using Local and Dim can only be used the first time when the object is created. After that they'll be deleted.)

also it can be confusing that the name should be Autoit3 Orginal and not Autoit3 Original

Link to comment
Share on other sites

Well obviously anything you can do with this you could do without it, or it wouldn't work... then again I never really saw OO as that big of a benefit.

[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Link to comment
Share on other sites

recompiled script Heres an unicode version with the autoit exe spelled correctly

Edit: uploading

Edit: http://www.sendspace.com/file/1px67j

Edited by mmavipc

[size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...