Jump to content

FreeStyle - Release - another, better preprossessor for AutoIt3


jennico
 Share

Recommended Posts

Hi World !

this is a (good working) beta release. i need some testing, comments, improvements, bug reports. it's a really big project.

;#=#INDEX#=========================================================#
;#Title .........: FreeStyle v 0.93 for AutoIt3 
;#Date ..........: 12.7.08
;#Theme..........: 1.) Administrate Includes Library, full text search, find, view and edit Global Constants and UDF 
;#  2.) Browse, find and run single UDF helpfiles and examples
;#  3.) Patch scripts, free them from Includes, insert Global Constant Values and necessary UDF
;#  4.) FreeStyle customized Editor (under construction)
;#Object.........: make scripts resistant to 'script-breaking changes' in AutoIt
;#  improve handling and testing of includes, examples and helpfiles
;#  UDF resources and Information Central
;#Status.........: beta testing version, most features available
;#  Library functions almost completely working, duplicates handling under heavy construction
;#  At this state, please ignore or overwrite duplicates, do not enumerate them !
;#  Enumerating entries still experimental
;#  Library perfectly handles Enums, Arrays and even PaulIA's linebreaking dll definitions ! :-)
;#  Patching still slow but working, in nearly all cases without additional manual work
;#  Exception: IE.au3 and Word.au3 don't work yet
;#  drag and droppable for Includes, scripts and directoriers, drop-pass-thru 99% working
;#  Search function (almost?) complete
;#  Editor still very basic, only one window possible yet
;#  clip working, paste not yet
;#  og and history features (restore points) not yet implemented
;#  skipped files and summary reports (messageboxes) are still nonsense, please ignore them
;#  lots of planned features to be added
;#  command line param handling to be added
;#  integration to SciTE and AutoIt preprocessing function planned, context menu and SciTE hotkey
;#  this program is constantly scraping AutoIt limitations and works beyond them
;#OS.............: Win XP SP2, does not work on Win9x (I presume)
;#  Vista not tested !
;#AutoIt Version.: v 3.2.8.1 and above (no includes, no need to update, no dependency on future AutoIt changes)
;#Author ........: jennico (jennicoattminusonlinedotde)
;#Credits to.....: Smoke for advanced and incredibly fast (!!!) ini section reading
;#  lokster, who helped me out with scilexer.dll and _scilexer.au3
;#  all the others who may find parts of their scriplets in here
;#  the complete AutoIt team for their brilliant work and constant improving
;#My Wishes......: Someone(s) to help me speed up scanning, searching and patching processes with StrRegExp/Replace
;#  Someone(s) to help me patching scripts with IE.au3 and Word.au3 included (object errors)
;#===================================================================#

- defends your scripts from future script breaking changes in AutoIt.

- makes old scripts work again.

- no need to search the include files for a special function or constant.

- no more guiconstants, windows constants and so on

- shrinks the size of your exes dramatically.

- add your own scripted functions or example scripts so you will always be able to easily find and integrate them to your new scripts !

Please i need lots of comments in order to continue this project !

j.

Edit: i hoped for a little more participation on this theme !

FreeStyle_0.93.zip

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

  • Replies 53
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

This is awesome muttley

I found a problem though, when installing the script it stated that StructureConstants.au3 was not needed. This caused my GDI+ scripts to fail since they use the struct declaration that lies in StructureConstants.au3

Anyways, Great Job :)

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

wow, what a fast reply !!!

i am still editing the first post !

well, okay, you have to tell FreeStyle what library you want to use. you can add your own include files and put the ones you don't like to be referenced into the ignorelist !

j.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

ah, structureconstants.au3 will only be added if you update your library with the "non-uppercase constants" checkbox checked.

on first start, FreeStyle will primarily register only the "clean" uppercase constants (like $WS_POPUP), because the non-uppercase constants are sometimes not reliable (like $state, $line, $open and so on).

all the constants used by PaulIA begin with $tag... this is lowercase.

so update your library with non-uppercase and structureconstants will be to your disposition !

j.

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

wow, what a fast reply !!!

i am still editing the first post !

well, okay, you have to tell FreeStyle what library you want to use. you can add your own include files and put the ones you don't like to be referenced into the ignorelist !

j.

I still doesn't understand why it didn't want to include StructureConstants.au3 into the library.

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

working now ??? muttley :):(

i took very special care of those (au3lib) constants, because they are somewhat difficult to handle..... but i think i made it !

j.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

Hi

awesome idea and very well implemented! Thanks a lot for this great script.

I was just thinking about creating a script that would search for and replace Constants and include files,

when I saw your posting. - So, great timing! ;-)

On my first test of your script, everything except one little thing was working and is just great!

I tried your script with one of Siao's scripts (found here: http://www.autoitscript.com/forum/index.php?showtopic=56536), that I was just testing and trying to get to work. On the end of the script is a variable that probably wasn't found by your script and thus replaced with a string with the same name.

Return $GUI_RUNDEFMSG

became

Return "GUI_RUNDEFMSG"

So, that needs some modification, like replace only the constants and variables you found values for.

Keep up the great work!

EDIT: Uups, I'm sorry, I just figured out that this string is the actual value for this Global Const.

But I'm curious about the following log line: Not found any Global Const in "myscript.au3"

-> There are some Global Const's set on the top of the script itself. Does your script not replace them by design, or might this be a bug?

Edited by Mojo
You can fool some of the people all of the time, and all of the people some of the time, but you can not fool all of the people all of the time. Abraham Lincoln - http://www.ae911truth.org/ - http://www.freedocumentaries.org/
Link to comment
Share on other sites

been trying, i can't get your original script to start. maybe you have an include file in the scriptdirectory ?

j.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

Hi

awesome idea and very well implemented! Thanks a lot for this great script.

I was just thinking about creating a script that would search for and replace Constants and include files,

when I saw your posting. - So, great timing! ;-)

On my first test of your script, everything except one little thing was working and is just great!

I tried your script with one of Siao's scripts (found here: http://www.autoitscript.com/forum/index.php?showtopic=56536), that I was just testing and trying to get to work. On the end of the script is a variable that probably wasn't found by your script and thus replaced with a string with the same name.

CODEReturn $GUI_RUNDEFMSG

became

CODEReturn "GUI_RUNDEFMSG"

So, that needs some modification, like replace only the constants and variables you found values for.

Keep up the great work!

thank you first !!

and second, this is correct !!!!! i don't know what's the sense, and it sounds like a joke, but $GUI_RUNDEFMSG really is "GUI_RUNDEFMSG" !!!! check it out !

so don't worry, it is not a bug, it's correct !

j.

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

to all:

please keep on linking me scripts that do not work, there is always the chance to find something unexspected to be fixed !

j.

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

But I'm curious about the following log line: Not found any Global Const in "myscript.au3"

-> There are some Global Const's set on the top of the script itself. Does your script not replace them by design, or might this be a bug?

no, FreeStyle will and can not replace constants that are defined in the script. you cannot redeclare a Global Constant, so this would result in an error.

in fact, it first checks if the const is already declared, and then skips it.

you can comment out your definitions on top of your script, and then FreeStyle will be free to replace them !

j.

Edit: uups, sorry, commenting out doesn't help, because at this point my script cannot yet handle outcommented constants, this is a thing that i have to implement soon, so you have to erase your definitions first !!!!

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

been trying, i can't get your original script to start. maybe you have an include file in the scriptdirectory ?

j.

Thanks for your replies.

I don't have any additional includefiles in my include folder. The only thing I changed before I ran it thru your pre-processor, was that I added

#include <WindowsConstants.au3>

After that and pre-processing it with FreeStyle, it runs as it should.

Are you planning on adding an option to also replace the Global Const's declared and defined in the script itself?

The log file said: Not found any Global Const in "C:\ShellHookwindow.au3"

I also get 4 errors and 1 warning when running your script in scite. However, if I ignore them the app still starts.

You can fool some of the people all of the time, and all of the people some of the time, but you can not fool all of the people all of the time. Abraham Lincoln - http://www.ae911truth.org/ - http://www.freedocumentaries.org/
Link to comment
Share on other sites

Are you planning on adding an option to also replace the Global Const's declared and defined in the script itself?

well, i could do it, but what's the sense ? FreeStyle is made to add missing constants and functions from includes, why should it replace properly defined constants within the script ?

i could implement it as an additional feature, but it's not necessary.

i am glad that it's working now for you ! muttley

I also get 4 errors and 1 warning when running your script in scite.

i do not use that anymore, because these "errors" are very picky ....

a script works, when it runs without errors, no matter what kind of convention you might have injured.

j.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

What I meant was replacing the $constants with their values in the script, not redeclaring them.

That doesn't help with readability for sure, but it could have some positive effect on the app size and speed.

Would only make sense for compilation. One could create a copy of his/her current script, run it thru FreeStyle and then compiling it.

I'm not an expert but I could imagine a good speed improvement this way. Especially for bigger scripts.

You can fool some of the people all of the time, and all of the people some of the time, but you can not fool all of the people all of the time. Abraham Lincoln - http://www.ae911truth.org/ - http://www.freedocumentaries.org/
Link to comment
Share on other sites

@ monoceres:

i worked on your "snow.au3", correcting some bugs in FreeStyle, and that's what i got:

#Region --- Script patched by FreeStyle code Start 08.07.2008 - 23:49:22


#EndRegion --- Script patched by FreeStyle code End
;#Include <GDIPlus.au3>
;#Include <WINAPi.au3>
;#Include <windowsconstants.au3>
;#Include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1)
Global $width = 640, $height = 480
Global $flakes = 250
Global $particles[$flakes][5],$giGDIPRef=0,$ghGDIPDll=0; had to add these manually
$hwnd = GUICreate("Cabin", $width, $height)
GUISetState()
GUISetOnEvent(-3, "close")

; All the GDI+ resources we gonna use
_GDIPlus_Startup()
$graphic = _GDIPlus_GraphicsCreateFromHWND($hwnd)
$bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphic)
$brush = _GDIPlus_BrushCreateSolid(0xAFFFFFFF)
$background = _GDIPlus_ImageLoadFromFile("background.jpg")
$backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)

GUIRegisterMsg(15,"_ReDraw")

; Create the flakes
For $i = 0 To UBound($particles) - 1
    $particles[$i][0] = Random(0, $width, 1)
    $particles[$i][1] = Random(0, $height, 1)
    $particles[$i][2] = 0
    $particles[$i][3] = Random(1, 3)
    $particles[$i][4] = Random(1, 3, 1)

Next

Local $count=0
Do
    ; Not important, just for fps
    $count+=1
    $timer=TimerInit()
    Sleep(20)
    
    ; Clear the backbuffer and draw the image on it.
    _GDIPlus_GraphicsClear($backbuffer, 0xFF000000)
    _GDIPlus_GraphicsDrawImageRect($backbuffer, $background,0,0,$width,$height)
    
    ; Loop through all the flakes
    For $i = 0 To UBound($particles) - 1
        ; If a flake has fallen below ths screen, re-use it
        If $particles[$i][1] > $height Then
            $particles[$i][0] = Random(0, $width, 1)
            $particles[$i][1] = 0
            $particles[$i][2] = 0
            $particles[$i][3] = Random(1, 3)
            $particles[$i][4] = Random(1, 3, 1)
        EndIf

        
        ; Move the flake
        $particles[$i][0] += $particles[$i][2]
        $particles[$i][1] += $particles[$i][3]
        ; Draw the flake on the backbuffer
        _GDIPlus_GraphicsFillEllipse($backbuffer, $particles[$i][0], $particles[$i][1], $particles[$i][4], $particles[$i][04], $brush)
    Next
    ; Draw the backbuffer into the screen
    _GDIPlus_GraphicsDrawImage($graphic, $bitmap, 0, 0)
    
    ; Display fps in console
    If Mod($count,20)=0 Then ConsoleWrite("Framrate: "&Round((1000/TimerDiff($timer)),1)&" fps."&@CRLF)
Until False

Func close()
    ; Clean up
    _GDIPlus_GraphicsDispose($graphic)
    _GDIPlus_BrushDispose($brush)
    _WinAPI_DeleteObject($bitmap)
    _WinAPI_DeleteObject($background)
    _GDIPlus_GraphicsDispose($backbuffer)
    _GDIPlus_Shutdown()
    Exit
EndFunc   ;==>close
;



Func _ReDraw()
    _GDIPlus_GraphicsDrawImage($graphic, $bitmap, 0, 0)
    Return "GUI_RUNDEFMSG"
EndFunc



#Region --- Script patched by FreeStyle code Start 08.07.2008 - 23:49:22

Func _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
    Local $aResult

    $aResult = DllCall($ghGDIPDll, "int", "GdipCreateBitmapFromGraphics", "int", $iWidth, "int", $iHeight, "hwnd", $hGraphics, _
            "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[4])
EndFunc   ;==>_GDIPlus_BitmapCreateFromGraphics

Func _GDIPlus_BrushCreateSolid($iARGB = 0xFF000000)
    Local $aResult

    $aResult = DllCall($ghGDIPDll, "int", "GdipCreateSolidFill", "int", $iARGB, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[2])
EndFunc   ;==>_GDIPlus_BrushCreateSolid

Func _GDIPlus_BrushDispose($hBrush)
    Local $aResult

    $aResult = DllCall($ghGDIPDll, "int", "GdipDeleteBrush", "hwnd", $hBrush)
    If @error Then Return SetError(@error, @extended, False)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc   ;==>_GDIPlus_BrushDispose

Func _GDIPlus_GraphicsClear($hGraphics, $iARGB = 0xFF000000)
    Local $aResult

    $aResult = DllCall($ghGDIPDll, "int", "GdipGraphicsClear", "hwnd", $hGraphics, "int", $iARGB)
    If @error Then Return SetError(@error, @extended, False)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc   ;==>_GDIPlus_GraphicsClear

Func _GDIPlus_GraphicsCreateFromHWND($hWnd)
    Local $aResult

    $aResult = DllCall($ghGDIPDll, "int", "GdipCreateFromHWND", "hwnd", $hWnd, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[2])
EndFunc   ;==>_GDIPlus_GraphicsCreateFromHWND

Func _GDIPlus_GraphicsDispose($hGraphics)
    Local $aResult

    $aResult = DllCall($ghGDIPDll, "int", "GdipDeleteGraphics", "hwnd", $hGraphics)
    If @error Then Return SetError(@error, @extended, False)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc   ;==>_GDIPlus_GraphicsDispose

Func _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, $iX, $iY, $iW, $iH)
    Local $aResult

    $aResult = DllCall($ghGDIPDll, "int", "GdipDrawImageRectI", "hwnd", $hGraphics, "hwnd", $hImage, "int", $iX, "int", $iY, "int", $iW, "int", $iH)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc   ;==>_GDIPlus_GraphicsDrawImageRect

Func _GDIPlus_GraphicsFillEllipse($hGraphics, $iX, $iY, $iWidth, $iHeight, $hBrush = 0)
    Local $aResult, $tmpError, $tmpExError

    _GDIPlus_BrushDefCreate($hBrush)
    $aResult = DllCall($ghGDIPDll, "int", "GdipFillEllipseI", "hwnd", $hGraphics, "hwnd", $hBrush, "int", $iX, "int", $iY, _
            "int", $iWidth, "int", $iHeight)
    $tmpError = @error
    $tmpExError = @extended
    _GDIPlus_BrushDefDispose()
    If $tmpError Then Return SetError($tmpError, $tmpExError, False)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc   ;==>_GDIPlus_GraphicsFillEllipse

Func _GDIPlus_ImageGetGraphicsContext($hImage)
    Local $aResult

    $aResult = DllCall($ghGDIPDll, "int", "GdipGetImageGraphicsContext", "hwnd", $hImage, "int*", 0)
    If @error Then Return SetError(@error, @extended, -1)
    Return SetError($aResult[0], 0, $aResult[2])
EndFunc   ;==>_GDIPlus_ImageGetGraphicsContext

Func _GDIPlus_ImageLoadFromFile($sFileName)
    Local $aResult

    $aResult = DllCall($ghGDIPDll, "int", "GdipLoadImageFromFile", "wstr", $sFileName, "int*", 0)
    If @error Then Return SetError(@error, @extended, -1)
    Return SetError($aResult[0], 0, $aResult[2])
EndFunc   ;==>_GDIPlus_ImageLoadFromFile

Func _GDIPlus_Shutdown()
    If $ghGDIPDll = 0 Then Return SetError(-1, -1, False)

    $giGDIPRef -= 1
    If $giGDIPRef = 0 Then
        DllCall($ghGDIPDll, "none", "GdiplusShutdown", "ptr", $giGDIPToken)
        DllClose($ghGDIPDll)
        $ghGDIPDll = 0
    EndIf
    Return True
EndFunc   ;==>_GDIPlus_Shutdown

Func _GDIPlus_Startup()
    Local $pInput, $tInput, $pToken, $tToken, $aResult

    $giGDIPRef += 1
    If $giGDIPRef > 1 Then Return True

    $ghGDIPDll = DllOpen("GDIPlus.dll")
    _WinAPI_Check("_GDIPlus_Startup (GDIPlus.dll not found)", @error, False)

    $tInput = DllStructCreate("int Version;int Callback;int NoThread;int NoCodecs")
    $pInput = DllStructGetPtr($tInput)
    $tToken = DllStructCreate("int Data")
    $pToken = DllStructGetPtr($tToken)
    DllStructSetData($tInput, "Version", 1)
    $aResult = DllCall($ghGDIPDll, "int", "GdiplusStartup", "ptr", $pToken, "ptr", $pInput, "ptr", 0)
    If @error Then Return SetError(@error, @extended, False)
    $giGDIPToken = DllStructGetData($tToken, "Data")
    Return $aResult[0] <> 0
EndFunc   ;==>_GDIPlus_Startup

Func _WinAPI_DeleteObject($hObject)
    Local $aResult

    $aResult = DllCall("GDI32.dll", "int", "DeleteObject", "int", $hObject)
    If @error Then Return SetError(@error, 0, False)
    Return $aResult[0] <> 0
EndFunc   ;==>_WinAPI_DeleteObject

Func _GDIPlus_BrushDefCreate(ByRef $hBrush)
    If $hBrush = 0 Then
        $ghGDIPBrush = _GDIPlus_BrushCreateSolid()
        $hBrush = $ghGDIPBrush
    EndIf
EndFunc   ;==>_GDIPlus_BrushDefCreate

Func _GDIPlus_BrushDefDispose()
    If $ghGDIPBrush <> 0 Then
        _GDIPlus_BrushDispose($ghGDIPBrush)
        $ghGDIPBrush = 0
    EndIf
EndFunc   ;==>_GDIPlus_BrushDefDispose

Func _WinAPI_Check($sFunction, $fError, $vError, $fTranslate = False)
    If $fError Then
        If $fTranslate Then $vError = _WinAPI_GetLastErrorMessage()
        _WinAPI_ShowError($sFunction & ": " & $vError)
    EndIf
EndFunc   ;==>_WinAPI_Check

Func _WinAPI_GetLastErrorMessage()
    Local $tText

    $tText = DllStructCreate("char Text[4096]")
    _WinAPI_FormatMessage(4096, 0, _WinAPI_GetLastError(), 0, DllStructGetPtr($tText), 4096, 0)
    Return DllStructGetData($tText, "Text")
EndFunc   ;==>_WinAPI_GetLastErrorMessage

Func _WinAPI_ShowError($sText, $fExit = True)
    _WinAPI_MsgBox(266256, "Error", $sText)
    If $fExit Then Exit
EndFunc   ;==>_WinAPI_ShowError

Func _WinAPI_FormatMessage($iFlags, $pSource, $iMessageID, $iLanguageID, $pBuffer, $iSize, $vArguments)
    Local $aResult

    $aResult = DllCall("Kernel32.dll", "int", "FormatMessageA", "int", $iFlags, "hwnd", $pSource, "int", $iMessageID, "int", $iLanguageID, _
            "ptr", $pBuffer, "int", $iSize, "ptr", $vArguments)
    Return $aResult[0]
EndFunc   ;==>_WinAPI_FormatMessage

Func _WinAPI_MsgBox($iFlags, $sTitle, $sText)
    BlockInput(0)
    MsgBox($iFlags, $sTitle, $sText & "      ")
EndFunc   ;==>_WinAPI_MsgBox


#EndRegion --- Script patched by FreeStyle code End

i don't know why but i keep getting a heavy "AutoIt.exe Error" on executing this (after gui shows). maybe my pc is out of date or it is because i don't have the "background.jpg".

i will release a fixed version later.

j.

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

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