Jump to content

AutoIt3 Interpreter.


Mat
 Share

Recommended Posts

I don't think you want to go down that road... Either way, it's over my head and I have no desire to learn about COM that deeply. You would basically be re-implementing AutoIt's COM implementation. Sound like fun?

Edited by wraithdu
Link to comment
Share on other sites

I don't think you want to go down that road... Either way, it's over my head and I have no desire to learn about COM that deeply. You would basically be re-implementing AutoIt's COM implementation. Sound like fun?

No... Functions then? I'll add a notice saying functions are working except setting property values.

Link to comment
Share on other sites

  • 2 months later...

Version 1.0.2.5 released

You can now use Chr(26) without having any fear of it messing up. Although I'm not entirely sure how you got a non-printing character into the console it's still a morale victory for doing the job properly. Thats about it for this release... The helpfile is not updated, but there are a few bits that may be of interest to you if you want to help out: I've added (commented out at the moment) the basic code for getting functions off the user. You will also notice the "now what?" at the bottom of the function. Feel free to try out solutions ;) There is also my attempt to detect when someone tries to close the console and to backup the settings. As you can probably guess this is not working either (it just doesn't do anything).

Download

Project page

Changelog

Bug tracker

Mat

Link to comment
Share on other sites

Brilliant idea, this is what has been missing and I cant understand why!

Im not very good at using AutoIt - I just tinker with it a bit, never really got to grips with it. for a Novice this is a great help and has re-kindled my interest in AutoIt. THANKS! ;)

ps I think it should be included in the

AutoIt install by default - as its a great help to beginners.

Edited by Hellooopsforgotsendcommand
Link to comment
Share on other sites

Brilliant idea, this is what has been missing and I cant understand why!

Im not very good at using AutoIt - I just tinker with it a bit, never really got to grips with it. for a Novice this is a great help and has re-kindled my interest in AutoIt. THANKS! ;)

ps I think it should be included in the

AutoIt install by default - as its a great help to beginners.

Thats what ists here for :) Tinkering.

It has WAY too many limitations to be anywhere near being included in the AutoIt installation, I think the only way thats going to happen is to use the AutoIt source code itself, and use the current interpreters logic instead of my own (and in many places Wraithdu's) attempt to simulate it.

The other good news is that I am now fixing a few more problems I have found ;)

Mat

Link to comment
Share on other sites

Thats what ists here for ;) Tinkering.

It has WAY too many limitations to be anywhere near being included in the AutoIt installation, I think the only way thats going to happen is to use the AutoIt source code itself, and use the current interpreters logic instead of my own (and in many places Wraithdu's) attempt to simulate it.

The other good news is that I am now fixing a few more problems I have found :)

Mat

I still think it should be easier to "come across" for an aid to beginners. Maybe mentioned on a tutorials page or something. I just come across it by accident a few days ago! would have been great to have had this from the start. keep up the good work!
Link to comment
Share on other sites

  • 2 months later...

When you run it... You should get a command prompt like this:

AutoIt3 Interpreter version: 1.0.2.5
Copyright (c) Matt Diesel (Mat) 2010

Au3Int ->

You can then type in lines of AutoIt code and see what happens in real time. In it's simplest form, you can use it for maths:

Au3Int -> 5 * 6 - 2 ^ 4
=> 14

But if you want to know how to use MouseGetPos... Try it:

Au3Int -> MouseGetPos()
=> Array[2]
     [0] => 897
     [1] => 285
Au3Int -> MouseGetPos(0)
=> 897
Au3Int -> MouseGetPos(1)
=> 285

Arrays were a pain to get working (read the code to see hard it was). But try this:

Au3Int -> Local $aMyArray[5][2] = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]
=> Array[5][2]
     [0][0] => 1
     [0][1] => 2
     [1][0] => 3
     [1][1] => 4
     [2][0] => 5
     [2][1] => 6
     [3][0] => 7
     [3][1] => 8
     [4][0] => 9
     [4][1] => 10
Au3Int -> ReDim $aMyArray[4][2]
=> Array[4][2]
     [0][0] => 1
     [0][1] => 2
     [1][0] => 3
     [1][1] => 4
     [2][0] => 5
     [2][1] => 6
     [3][0] => 7
     [3][1] => 8
Au3Int -> ReDim $aMyArray[4][1]
=> Array[4][1]
     [0][0] => 1
     [1][0] => 3
     [2][0] => 5
     [3][0] => 7

Basically, if you want to test out how a line of code will work, then this is the best way to do it.

To debug scripts... Run Au3Int.exe with the file as the first parameter to read all the output... But thats not really needed when you have scite, it's just there for when you need to read the output on computers where there is no AutoIt.

Does that explain it?

Link to comment
Share on other sites

When you run it... You should get a command prompt like this:

AutoIt3 Interpreter version: 1.0.2.5
Copyright (c) Matt Diesel (Mat) 2010

Au3Int ->

You can then type in lines of AutoIt code and see what happens in real time. In it's simplest form, you can use it for maths:

Au3Int -> 5 * 6 - 2 ^ 4
=> 14

But if you want to know how to use MouseGetPos... Try it:

Au3Int -> MouseGetPos()
=> Array[2]
    [0] => 897
    [1] => 285
Au3Int -> MouseGetPos(0)
=> 897
Au3Int -> MouseGetPos(1)
=> 285

Arrays were a pain to get working (read the code to see hard it was). But try this:

Au3Int -> Local $aMyArray[5][2] = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]
=> Array[5][2]
    [0][0] => 1
    [0][1] => 2
    [1][0] => 3
    [1][1] => 4
    [2][0] => 5
    [2][1] => 6
    [3][0] => 7
    [3][1] => 8
    [4][0] => 9
    [4][1] => 10
Au3Int -> ReDim $aMyArray[4][2]
=> Array[4][2]
    [0][0] => 1
    [0][1] => 2
    [1][0] => 3
    [1][1] => 4
    [2][0] => 5
    [2][1] => 6
    [3][0] => 7
    [3][1] => 8
Au3Int -> ReDim $aMyArray[4][1]
=> Array[4][1]
    [0][0] => 1
    [1][0] => 3
    [2][0] => 5
    [3][0] => 7

Basically, if you want to test out how a line of code will work, then this is the best way to do it.

To debug scripts... Run Au3Int.exe with the file as the first parameter to read all the output... But thats not really needed when you have scite, it's just there for when you need to read the output on computers where there is no AutoIt.

Does that explain it?

sure ... thanks; i thought that it will run a line then pause to see what that line did ... or something like this ...

[center]Sorry for my bad english. Trying my best :Dhttp://iulianonofrei.comhttp://www.last.fm/user/Revolt666 [/center]

Link to comment
Share on other sites

This seems strange. Bug?

AutoIt3 Interpreter version: 1.0.2.5
Copyright ® Matt Diesel (Mat) 2010

Au3Int -> ConsoleWrite("roflkek")
=> 7
Au3Int ->

I was expecting output: roflkek. What happen?

Edit: Oh nvm, I'm supposed to put "roflkek" in there, instead of using ConsoleWrite. My bad.

Edit2: Then why not this:

AutoIt3 Interpreter version: 1.0.2.5
Copyright ® Matt Diesel (Mat) 2010

Au3Int -> FileRead("au3int.chm")
Au3Int -> $file = FileRead("au3int.chm")
Au3Int -> $file
Au3Int ->

Too big? I'd like a notice if that's the case.

Edit3:

AutoIt3 Interpreter version: 1.0.2.5
Copyright ® Matt Diesel (Mat) 2010

Au3Int -> Exit
= > Error: Missing separator character after keyword.:
Axit
Axit^ ERROR
Au3Int ->

Edit4: Software and alcohol do not mix. Don't let anyone else tell you otherwise.

Edited by Manadar
Link to comment
Share on other sites

The first one doesn't work, for the simple reason that it doesn't. Try:

Au3Int -> $hKERNEL32 = 'Kernel32.dll'
=> "Kernel32.dll"
Au3Int -> $hConsole = DllCall($hKERNEL32, "handle", "GetStdHandle", "dword", -11)
=> Array[2]
     [0] => 0x00000007
     [1] => 4294967285
Au3Int -> $hConsole = $hConsole[0]
Obscure instruction.
Do you want to re-assign 'hConsole'? y/n y
=> 0x00000007
Au3Int -> $sText = 'test'
=> "test"
Au3Int -> DllCall($hKERNEL32, "bool", "WriteConsoleA", "handle", $hConsole, "str", $sText, "dword", StringLen($sText), "dword*", 0, "ptr", 0)
test=> Array[6]
     [0] => 1
     [1] => 0x00000007
     [2] => "test"
     [3] => 4
     [4] => 4
     [5] => 0x00000000

Not sure about the next one, there is no internal check (though it was considered). Must be a windows limitation, I'll do some reading. Other files read fine btw. I think a limit should be placed on the output though... Any suggestions on length etc? Certainly my current method for printing arrays is way off being able to predict the output size (the function simply calls itself as many times as needs be). Possibly related to this item on the issue tracker: http://code.google.com/p/au3int/issues/detail?id=10

That last one can't be right. But testing it did find a few other bugs, not least the fact that I haven't actually released the latest version. So here it is. 1.0.2.6.

Mat

Edit: Lets do this properly:

Changes this version (1.0.2.6): [ see full changelog ]

NB: This version is no longer the latest.

  • Settings saved on exit for the console (needs to be tested more thoroughly)
  • Source code tidy up.
  • Updated console functions. The full library is work in progress here.
  • A few bugs fixed. It's been sitting around for a while, so I needed to run a diff to find out what id done!
The svn repository has not been updated (yet).

Download

Project page

Changelog

Bug tracker

Edited by Mat
Link to comment
Share on other sites

Mat,

I have some very strange problems when using the compiled latest release 1.0.2.6

1. When I first run the interpreter, type "help" for example, then straight after, "clear", the "help" command is left in the first buffer position.

2. Try doing the following:

  • $var = true
  • if $var then msgbox(0, "", "Hai durrr")
  • "= > Error: Variable used without being declared."
  • local $var = true
  • "Blah blah, variable is already declared blah bah"
Food.
Link to comment
Share on other sites

I can explain that, and hopefully fix it.

Step 1) Execute fails as it can't deal with full IF tests.

Step 2) The interpreter tries to get more error information, by executing the line using the command line parameter and reading stderr. BUT this is not good as it finds that $var is not declared. It wouldn't have found an error anyhow.

Solution: Custom IF test parsing. Will do :(

I have also uploaded a proof of concept for version 2. Still a bit dodgy, and you guys are finding enough bugs in the current version anyway. Try it, you can use includes and functions, but no nested statements yet, they are a little tricky. I think it could work though.

Anything else I should know about :graduated:

Edit: I fixed it, and re built + uploaded the new version. The If tests work beautifully.

Edited by Mat
Link to comment
Share on other sites

That's odd, I don't have any of Manadar's weird errors with my compiled version of 1.0.2.5. And 'Exit' works just fine.

@Manadar

Did you compile your own version of Au3Int and not obfuscate the source code? That could cause some internal variable collisions or something...

I also get the odd behavior of FileRead, but if you do a VarGetType() on the var, it is a string. Could be there are some non-printable chars or nuls which would mess up the display.

AutoIt3 Interpreter version: 1.0.2.5
Copyright c Matt Diesel (Mat) 2010

Au3Int -> $file = FileRead("au3int.chm")
Au3Int -> VarGetType($file)
=> "String"
Au3Int -> StringLen($file)
=> 229959
Au3Int -> BinaryLen($file)
=> 229959
Link to comment
Share on other sites

Manadars error with the exit was so weird I ignored it. How he got himself that is unknown to me.

I'm assuming the strings too large for the console. Maybe it's a good thing it doesn't print it. However, this page does not have any mention of it: http://msdn.microsoft.com/en-us/library/ms687401.aspx

Edit: I would have thought non printing characters would be fine... And nuls would just act as the end of the string... (Maybe not)

WTF!! I'm guessing error No. 1 is that it's trying to print a unicode string as ascii. Error No 2 is that isn't what it should be at all.

AutoIt3 Interpreter version: 1.0.2.7
Copyright (c) Matt Diesel (Mat) 2010

Au3Int -> $file = FileRead('au3int.chm')
Au3Int -> StringLeft($file, 1)
=> "I"
Au3Int -> StringLeft($file, 200)
 > "ITSF♥   ♥   I n t e r p r e t e r   v e r s i o n :   1 . 0 . 2 . 7
 C o p y r i g h t   ( c )   M a t t   D i e s e l   ( M a t )   2 0 1 0

   F i l e V e r s i o n     1 . 0 . 2 . 7   b % ☺ CAu3Int ->
Edited by Mat
Link to comment
Share on other sites

So I downloaded and compiled 1026. Changes look fine to me, except I wouldn't ever delete 'HKCR\.au3'. You need to backup and restore the system's original file type settings if you ever use 'install' / 'uninstall' otherwise you risk blowing away someone's file types from an installation of AutoIt. You also need to consider the scenarios where someone issues 'install' or 'uninstall' twice in a row as well (ie installing when it's already installed, uninstalling after it's already uninstalled), and gracefully handle that.

EDIT:

Oh, and I kind of liked that issuing ConsoleWrite("hello") would actually print "hello", now it just shows the function's return value.

Edited by wraithdu
Link to comment
Share on other sites

It won't let you install if there's already something there, thats why. I figured the only time it was of use was when you are on a computer with no AutoIt. You can't install if it's already installed, and you can't uninstall unless it was installed using au3Int (it uses a different registry key: Au3IntTempScript)

ConsoleWrite has not printed "hello" since the early days. I never worked out why, although I assume it is related to the fact that I use the WinApi AllocConsole rather than compiling it as a normal console app. It should still be using the standard api to write to the console anyway. It's a long standing thing, and a pain in the arse. For my Console.au3 (here) you can't use ConsoleWrite with _Console_Alloc...

Next version will now only use _Console_Alloc for the non compiled versions. It will also remove AINTERNALARRAYWAT :graduated: I also fixed the bug that James pointed out about it not clearing the console properly.

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...