Jump to content

Recommended Posts

Posted (edited)

Well, in an attempt to reduce the size of my scripts I have created a script that strips other scripts of their comments, their unused global variables, and their unused functions.

This script should reduce the overall size of your scripts, for those of you that want to have the smallest uncompiled and compiled filesize possible.

New version 0.3.0.5!

New with version 0.3.0.5:

Fixed: Bug where functions in "" without () were deleted.

Added: Pass number to the progress.

Added: Now removes region and endregion tags

New with version 0.3.0.4:

  • GUI Added
  • Option for making multiple passes, reducing the script size further than ever before.
  • Automatically compiles all the include files into the script for you
  • Option to switch between the release version and beta version

I have tested this script on many of my own scripts, some around 5000 lines and have yet to encounter an error in the script due to the stripping. In addition, this script is capable of stripping obfuscated scripts that were obfuscated with something such as Encode It.

Important!

You can't use functions such as IsDeclared(), Assign(), Eval() and Call(). The use of these functions will result in a damaged final script.

ScriptStripperv0.3.0.5.au3

I am not responsible for any damaged scripts. This specifically copies the completed script to the clipboard to prevent and unintentional overwriting of your original script.

ALWAYS BACK UP YOUR SCRIPTS BEFORE OPTIMIZING OR MODIFYING THEM!

Please let me know of any bugs that you may encounter while using this.

Important!

You can't use functions such as IsDeclared(), Assign(), Eval() and Call(). The use of these functions will result in a damaged final script.

Suggestions for optimizing and improving the script are greatly appreciated.

Stripping Results:

A precompiled script(a script that has its headers included) before being stripped was 207KB and 5134 lines of code

The same script after being stripped was 36KB, 1022 lines long, did not need any include files.

The stripping process took 52 seconds to complete 5 passes.

Edited by The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Posted (edited)

80 views and no replies? You all know what this does right? It makes your scripts smaller in size as well as your compiled executables.

For example, a 5500 line script of mine was originally 223 KB. After i ran the script stripper above, the script was just 36KB. The final version is just 36% the size of the original. Pretty significant IMO.

Edited by The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Posted

Yes, just make sure you compile your script, decompile it, and then strip it. The reason why you want to compile it first and then decompile it is because when you compile it, it includes all the header files. When you decompile it the header files remain in the script and can then be removed by my script.

Overall, it should significantly reduce the size of your script and compiled executable.

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Posted (edited)

Yes, just make sure you compile your script, decompile it, and then strip it. The reason why you want to compile it first and then decompile it is because when you compile it, it includes all the header files. When you decompile it the header files remain in the script and can then be removed by my script.

Overall, it should significantly reduce the size of your script and compiled executable.

Maybe you could take this one step further....

Have it compile the dev's script, then decompile it, then run the stripper

you/we can use your stripper an exe file

8)

Edited by Valuater

NEWHeader1.png

Posted (edited)

Maybe you could take this one step further....

Have it compile the dev's script, then decompile it, then run the stripper

you/we can use your stripper an exe file

8)

Yeah, i had actually written another version that compiled it first and the likes, the only problem was that there were too many variables. The person didn't necessarily need to have autoit installed and if they did i would then have to have the script choose which version of autoit to compile, regular autoit or the beta. Then i would have to have it use the right include files. In the end it just turned out to be a massive pain and there was no guarantee it would work.

I've been using cleanscript but i'll definitely try this out

if you could read the include files and just add them first then there would be no need to compile

this is what cleanscript does

Yeah, i saw that peethebee released his right about when i was working on my version. I guess we both thought that something needed to be done to clean the scripts prior to compilation. I have tested peethebee's cleanscript and it is faster than my script. It is faster, but after five passes with my script, the size of the final script is even less.

Edited by The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

  • Moderators
Posted

Yeah, i had actually written another version that compiled it first and the likes, the only problem was that there were too many variables. The person didn't necessarily need to have autoit installed and if they did i would then have to have the script choose which version of autoit to compile, regular autoit or the beta. Then i would have to have it use the right include files. In the end it just turned out to be a massive pain and there was no guarantee it would work.

Well if they didn't have it installed, then they wouldn't have the opportunity to compile and decompile themselves would they :)

You could always just do a ... If FileExists().

And compiling and decompiling with their beta is usually the easiest saftest way to go IMHO. It's about 4 or 5 lines of code to do this.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

Allright then, i will make a GUI for it. I think i will have options similar to PeetheBee.

I have done some tests and while my script is significantly slower, it reduces the file size even more than PeetheBees after five or so passes. It just boils down to which script you would prefer to use.

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Posted

Allright then, i will make a GUI for it. I think i will have options similar to PeetheBee.

You would be better off having it as a pre-Autoit3wrapper script with options of silent run, prompt etc and then pass parameters to AutoIt3Wrapper. Making a Gui that only compiles to standard exe without Auto3Wrapper options used is a pointless exercise, IMHO. If you make a Gui that does prompt with stripping options, then that would be perhaps fruitful before runnig AutoIt3Wrapper. I use pre-Wrappers\Wrappers myself to set Scite4AutoIt3 to run the tools with personal custom options. That's just my view.

:)

  • Moderators
Posted

I have a question, on the 2 that are being used (Clean Script and Kandie Mans) are they only removing Global Const variables that aren't being used?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

You would be better off having it as a pre-Autoit3wrapper script with options of silent run, prompt etc and then pass parameters to AutoIt3Wrapper. Making a Gui that only compiles to standard exe without Auto3Wrapper options used is a pointless exercise, IMHO. If you make a Gui that does prompt with stripping options, then that would be perhaps fruitful before runnig AutoIt3Wrapper. I use pre-Wrappers\Wrappers myself to set Scite4AutoIt3 to run the tools with personal custom options. That's just my view.

:)

I see what you are saying. Without any advanced options when compiling the .exe, the whole thing is useless. Sorry if i am giving any confusion. I am now in the process of writing a new version that will take a script you specify, compile it so that the included files are placed with the main script, and decompile it so that it is back to an .au3 file but this time with the include files in it as well. Once it has done this, it will then strip the script and when it is done stripping the script it will then place the stripped script source code on your clipboard. I have it place the source code on your clipboard because it is a much more fool-proof way of outputting the code without the possibility of the user accidently overwriting their original or any other previous versions of their script. :P

I have a question, on the 2 that are being used (Clean Script and Kandie Mans) are they only removing Global Const variables that aren't being used?

It only removes Global Const. Yeah, i don't want it to mess with global variables that the user specifies.

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Posted

I have just posted the new version of my script stripper at the top of this thread:

http://www.autoitscript.com/forum/index.ph...st&p=238637

Things that are different from the old version are:

  • GUI Added

  • Option for making multiple passes, reducing the script size further than ever before.

  • Automatically compiles all the include files into the script for you

  • Option to switch between the release version and beta version

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

  • 10 months later...
Posted

Hey same idea here!

If you check out my sig, you'll see I've tackled the problem also.

As far as constants and the like are concerned, you should check out the excellent "Constants Generator" that enables a user to integrate all the constants in your AU3 file without ever using #include for constants (which bloats up the code like there's no tomorrow).

I've also show on that page how how to adapt Constants generator to the latest version of AutoIT.

Also if you have #include for other modules, you should consider integrating the functions you use into your AU3 file; unless you expect these includes to change in the future, it just makes more sense to have all your stuff integrated.

Hopefully this will help you squeeze even more juice out of AUtoIt3.

Obi Wan Celeri

BTW: I didn't check lately but last time I was around (2005ish) running FOR/NEXT loops was waaaay faster than DO/UNTIL and the lot. Worth checking out if you're crunching a lot of lines!

I am endeavoring, ma'am, to construct a mnemonic circuit using stone knives and bearskins.SpockMy UDFs:Deleted - they were old and I'm lazy ... :)My utilities:Comment stripperPolicy lister 1.07AutoIT Speed Tester (new!)

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
  • Recently Browsing   0 members

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