SciTE4AutoIt3: Difference between revisions

From AutoIt Wiki
Jump to navigation Jump to search
m (→‎Obfuscator: typo and expanded on the explanation.)
m (Improved arrangement, typos, rewording, etc)
Line 1: Line 1:
'''SciTE4AutoIt3''' is a specialist editor package based on the excellent [http://www.scintilla.org/SciTE.html SciTE] editor.  SciTE has been set up to compile AutoIt scripts and has been extended with a multitude of Lua scripts.  SciTE4AutoIt3 may be downloaded here: [http://www.autoitscript.com/site/autoit-script-editor/ SciTE4AutoIt3]
'''SciTE4AutoIt3''' is a specialist editor package based on the excellent [http://www.scintilla.org/SciTE.html SciTE] editor.   
 
SciTE has been set up to compile AutoIt scripts and has been extended with a multitude of Lua scripts.   
Keep in mind that SciTE4AutoIt3 is not an official package. Direct any bug reports or feature requests to the AutoIt3 forum and not the bug tracker.
SciTE4AutoIt3 may be downloaded here: [http://www.AutoItscript.com/site/AutoIt-script-editor/ SciTE4AutoIt3].
 
Keep in mind that SciTE4AutoIt3 is not an official package.
SciTE4AutoIt3 provides:
Direct any bug reports or feature requests to the AutoIt3 forum and not the bug tracker.
* Syntax highlighting
* Calltips (also known as IntelliSense)
* Code AutoComplete
* Auto Indentation
* AutoIt script help integration
* SciTE help integration
* Abbreviations
* Editing macros
* Debugging support
* Tools for AutoIt scripting
* A toolbar that enables easy access to an array of community created tools
* Various other features
 


__TOC__
__TOC__
Line 24: Line 11:
[[File:Syntax_Highlight.png|457px|thumb|right|A demonstration of syntax highlighting using the default theme.]]
[[File:Syntax_Highlight.png|457px|thumb|right|A demonstration of syntax highlighting using the default theme.]]


SciTE4AutoIt3 comes with a customized AutoIt3 lexer which enables syntax highlighting. Syntax highlighting enables the colorization of various code elements such as variables, strings, operators, comments, etc. This allows one to differentiate the various code elements at a glance without having to specifically read everything. To load a custom theme a user may press [Ctrl] + [1] to bring up [[SciTEConfig]]. The options are located under the ''Color Settings'' tab.
SciTE4AutoIt3 comes with a customized AutoIt3 lexer which enables syntax highlighting.
Syntax highlighting enables the colorization of various code elements such as variables, strings, operators, comments etc.
Syntax highlighting allows one to differentiate the various code elements such as keywords, variables, strings, control flow structures etc. quickly without having to specifically identify the element.
To load a custom theme a user may press [Ctrl] + [1] to bring up [[SciTEConfig]].
When the ''Color Settings'' tab is selected a button labeled 'New Scheme' will appear at the bottom.
Alternatively, the colors may be customized individually.


Some options that are available for customization include:
Some options that are available for customization include:
Line 38: Line 30:
= Quick Tips =
= Quick Tips =


To access the helpfile the user may press [Alt] + [F1].
For anyone not familiar with SciTE, here are a few tips and tricks to help easily customize the installation.
To quickly access help information on a specific function/statement, simply click/highlight the function/statement in question and press the [F1] key to bring up the help file on the relevant page.
For any advanced info, visit the [http://www.scintilla.org/SciTEDoc.html SciTE home page].


== Help Files ==
To access the AutoIt3 helpfile the user may press [F1]. 
To quickly access help information on a specific function, simply click or highlight the desired function and press the [F1] key to bring up the help file on the relevant page.
To access the SciTE4AutoIt3 helpfile the user may press [ctrl] + [F1].
For SciTE related help, use the key combination [Ctrl] + [F1] to bring up a help file detailing SciTE related help documentation.
For SciTE related help, use the key combination [Ctrl] + [F1] to bring up a help file detailing SciTE related help documentation.


For anyone not familiar with SciTE, here are a few tips and tricks to help easily customize the installation. For any advanced info, visit the [[http://www.scintilla.org/SciTEDoc.html SciTE home page]].
== Properties Files ==


With the information below, you will be doing some minor editing to SciTE's configuration files.
With the information below, you will be doing some minor editing to SciTE's configuration files.
Line 50: Line 47:
Remember there are four properties files used:
Remember there are four properties files used:


# ''SciTE.properties''
<table border='1'>
# ''SciTEDirectory.properties''
# ''SciTEUser.properties''
# ''SciTEGlobal.properties''
 
<table border="1">
<tr><td>SciTE.properties</td>
<tr><td>SciTE.properties</td>
<td>Local properties file which may be present in the same directory as the file being edited. This file overrides any other properties files settings below. This file is user created.</td></tr>
<td>Local properties file which may be present in the same directory as the file being edited. This file overrides any other properties files settings below. This file is user created.
</td></tr>


<tr><td>SciTEDirectory.properties</td>
<tr><td>SciTEDirectory.properties</td>
<td>Directory properties file which may be present in the same or in a parent directory as the file being edited. This file overrides all properties setting of the files below, but not the local properties settings aka ''SciTE.properties''. This file is user created.</td></tr>
<td>Directory properties file which may be present in the same or in a parent directory as the file being edited.
This file overrides all properties setting of the files below, but not the local properties settings aka ''SciTE.properties''.  
This file is user created.
</td></tr>


<tr><td>SciTEUser.properties</td>
<tr><td>SciTEUser.properties</td>
<td>User properties file, this file's settings override only the global properties settings aka ''SciTEGlobal.properties''. This file is found under the current logged on users profile directory.</td></tr>
<td>User properties file, this file's settings override only the global properties settings aka ''SciTEGlobal.properties''.
This file is found under the current logged on users profile directory.
</td></tr>


<tr><td>SciTEGlobal.properties</td>
<tr><td>SciTEGlobal.properties</td>
<td>All settings in this file can be overridden by any of the above files. Typically this file should not be edited. Use any of the above methods to implement a setting change. This file can be found in SciTE's installation directory.</td></tr>
<td>All settings in this file can be overridden by any of the above files.  
Typically this file should not be edited.  
Use any of the above methods to implement a setting change.
This file can be found in SciTE's installation directory.
</td></tr>
</table>
</table>


== Inline Errors ==
== Inline Errors ==


[[File:InlineError.JPG‎‎|234px|thumb|right|Intentional error prone code used to display the "Inline Error" feature.]]
[[File:InlineError.JPG|234px|thumb|right|Intentional error prone code used to display the "Inline Error" feature.]]


In the latest version of SciTE, there exists a new feature called "Inline Errors".  Inline Error marks are error messages that will appear in the source code within the Scintilla window.
In the latest version of SciTE, there exists a new feature called "Inline Errors".   
Inline Error marks are error messages that will appear in the source code within the Scintilla window.


Inline erros may be quickly toggled using ''SciTEUser.properties''.
Inline errors may be quickly toggled using ''SciTEUser.properties''.


Open the SciTE user properties file in a text editor by selecting from the SciTE menu ''Options''.  Open ''User Options File'' and add the following code to the file.
Open the SciTE user properties file in a text editor by selecting from the SciTE menu ''Options''.   
Open ''User Options File'' and add the following code to the file.


To disable:
To disable:
<syntaxhighlight lang="properties">
 
# Display settings for inline errors on the source
<syntaxhighlight lang="properties">error.inline=0</syntaxhighlight>
error.inline=0
</syntaxhighlight>


To enable:
To enable:


<syntaxhighlight lang="properties">
<syntaxhighlight lang="properties">error.inline=1</syntaxhighlight>
# Display settings for inline errors on the source
error.inline=1
</syntaxhighlight>


== Selection Highlighting ==
== Selection Highlighting ==


Syntax Highlighting is a new feature which highlights other instances of the currently highlighted word or string.  Due to the colors, sometimes it's hard to tell the selection apart.  The default colors may be changed.
Syntax Highlighting is a new feature which highlights other instances of the currently highlighted word or string.   
Due to the colors, sometimes it's hard to tell the selection apart.   
The default colors may be changed.


The feature may be toggled by editing ''SciTEUser.properties''.
The feature may be toggled by editing ''SciTEUser.properties''.
Line 110: Line 111:
<syntaxhighlight lang="properties">
<syntaxhighlight lang="properties">
highlight.current.word=1
highlight.current.word=1
# Edit the following property to change to the desired color.
# Edit the following property to change to the desired color.
highlight.current.word.colour=#000040
highlight.current.word.colour=#000040
selection.alpha=50
selection.alpha=50
# Edit the following property to change to the desired color.
# Edit the following property to change to the desired color.
selection.back=#F025A8
selection.back=#F025A8
Line 119: Line 123:
== Colors in the Output Pane ==
== Colors in the Output Pane ==


SciTE has a console window which can be used to output information from running scripts.  The function {{Help File|ConsoleWrite}} may be used in an AutoIt script to output text to the console.  The colors of the text may be altered by prepending a string with special characters.
SciTE has a console window which can be used to output information from running scripts.   
The function {{Help File|ConsoleWrite}} may be used in an AutoIt script to output text to the console.   
The colors of the text may be altered by prepending a string with special characters.


For example:
For example:
Line 133: Line 139:
== Debugging Code Easily ==
== Debugging Code Easily ==


<syntaxhighlight lang="autoit">
<syntaxhighlight lang="AutoIt">
dbg("This is a test")
dbg("This is a test")
dbg("Jump to this line")
dbg("Jump to this line")
Line 147: Line 153:
= AutoIt3Wrapper =
= AutoIt3Wrapper =


AutoIt3Wrapper directives allow for in depth control of the compilation and interpretation of AutoIt scripts.  Some of these can be very useful under different circumstances. See [[AutoIt3Wrapper Directives]] for a full list of directives and their descriptions.
AutoIt3Wrapper directives allow for in depth control of the compilation and interpretation of AutoIt scripts.   
Some of these can be very useful under different circumstances.
See [[AutoIt3Wrapper Directives]] for a full list of directives and their descriptions.


= Obfuscator =
= Obfuscator =


[[Obfuscator]] may be used to strip away unused [[Function|functions]] and [[Global|global]] [[Variable|variables]] from the script prior to compilation.  Functions and variables may be renamed to shorter three character names to save space and to provide some measure of obscurity.  Keep in mind that Obfuscator is not guaranteed protection against decompilation.
[[Obfuscator]] may be used to strip away unused [[Function|functions]] and [[Global|global]] [[Variable|variables]] from the script prior to compilation.   
Functions and variables may be renamed to shorter three character names to save space and to provide some measure of obscurity.   
Note that Obfuscator is not guaranteed protection against decompilation.


== Stripping Excess Code ==
== Stripping Excess Code ==
Line 172: Line 182:
  +> Obfuscator v1.0.27.0 finished obfuscating 1566 lines, created:C:\MyScript_Obfuscated.au3
  +> Obfuscator v1.0.27.0 finished obfuscating 1566 lines, created:C:\MyScript_Obfuscated.au3


== Using ResHacker ==
= Run_After and Run_Before Commands =


ResHacker is a very important programming tool for extracting and adding resources into executables. It has a very simple command line interface that allows it to be used easily using the "Run_After" directive. Adding a picture to an executable could be done like this:
== Running the exe On Build ==


#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, MyPicture.bmp, BITMAP, RESOURCENAME, 0
Often you are building as a test, so to have to open up Windows Explorer to find the exe is a pain.  
Furthermore, unless you have a program to do it (or it's a console program) you will not be able to read console info such as the debug messages you put in the exe.  
The solution is simple:


NB: Reshacker.exe ''must'' be copied into the script directory for this to work.
#AutoIt3Wrapper_Run_After="%out%"


If you then want to use the resources in your code, there is an excellent [http://www.autoitscript.com/forum/index.php?showtopic=51103 Resources UDF] which will allow you to access the resources from within the exe.
This will run the program and read the console output to the SciTE debug frame.


== Adding Original Source Code ==
== Creating a Version Directory ==


When using the above tip on stripping excess code, the new source is not readable. As a result, using the standard directive for saving the source:
When compiling, it is very possible that you want to go back to a previous version.  
If so, then it is neat to have a directory which will store all previous builds, without the need for you to manually copy and paste every time.
Make sure you add these directives in last (after adding resources) as they might not be included in the copied result.


  #AutoIt3Wrapper_Res_SaveSource=y
  #AutoIt3Wrapper_Run_After=md "%scriptdir%\Versions\%fileversion%"
#AutoIt3Wrapper_Run_After=copy "%in%" "%scriptdir%\Versions\%fileversion%\%scriptfile%%fileversion%.au3"
#AutoIt3Wrapper_Run_After=copy "%out%" "%scriptdir%\Versions\%fileversion%\%scriptfile%%fileversion%.exe"


Would add the obfuscated code to the exe, which is not the desired result. The solution is to add it in manually. This code does not require any editing, so you can just copy and paste it in:
== Using ResHacker ==


#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, %scriptfile%.au3, RCDATA, SOURCE, 0
ResHacker is a very important programming tool for extracting and adding resources into executables.  
It has a very simple command line interface that allows it to be used easily using the "Run_After" directive.  
Adding a picture to an executable could be done like this:


== Creating a Version Directory ==
#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, MyPicture.bmp, BITMAP, RESOURCENAME, 0


When compiling, it is very possible that you want to go back to a previous version. If so, then it is neat to have a directory which will store all previous builds, without the need for you to manually copy and paste every time! Make sure you add these directives in last (after adding resources) as they might not be included in the copied result.
NB: Reshacker.exe ''must'' be copied into the script directory for this to work.


#AutoIt3Wrapper_Run_After=md "%scriptdir%\Versions\%fileversion%"
If you then want to use the resources in your code, there is an excellent [http://www.AutoItscript.com/forum/index.php?showtopic=51103 Resources UDF] which will allow you to access the resources from within the exe.
#AutoIt3Wrapper_Run_After=copy "%in%" "%scriptdir%\Versions\%fileversion%\%scriptfile%%fileversion%.au3"
#AutoIt3Wrapper_Run_After=copy "%out%" "%scriptdir%\Versions\%fileversion%\%scriptfile%%fileversion%.exe"


== Running the exe on Build ==
=== Adding Original Source Code ===


Often you are building as a test, so to have to open up Windows Explorer to get the exe is a pain, furthermore, unless you have a program to do it (or it's a console program) you will not be able to read console info such as the debug messages you put in the exe. The solution is simple:
When using the above tip on stripping excess code, the new source is not readable.
As a result, using the standard directive for saving the source:


  #AutoIt3Wrapper_Run_After="%out%"
  #AutoIt3Wrapper_Res_SaveSource=y


This will run the program and read the console output to the SciTE debug frame.
Would add the obfuscated code to the exe, which is not the desired result.
The solution is to add it in manually.  
This code does not require any editing, so you can just copy and paste it in:


== Extended Reshacker Info ==
#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, %scriptfile%.au3, RCDATA, SOURCE, 0
=== Extended Reshacker Info ===


ResHacker doesn't always return with a return code (rc) of not 0 if it fails, to get that info you need to read the ResHacker.log file that is created. This is also pretty simple to do:
ResHacker doesn't always return with a return code (rc) of not 0 if it fails, to get that info you need to read the ResHacker.log file that is created. This is also pretty simple to do:
Line 250: Line 271:
[[Adding_UDFs_to_AutoIt_and_SciTE|Adding UDFs to AutoIt and SciTE]]
[[Adding_UDFs_to_AutoIt_and_SciTE|Adding UDFs to AutoIt and SciTE]]


=Useful Lua links and scripts=
= Useful Lua links and scripts =


[http://www.scintilla.org/SciTELua.html SciTELua]
[http://www.scintilla.org/SciTELua.html SciTELua]


[http://www.lua.org http://www.lua.org/]
[http://www.lua.org Lua Website]


[http://www.lua.org/pil/1.html Programming in Lua]
[http://www.lua.org/pil/1.html Programming in Lua]


[http://lua-users.org/wiki/ http://lua-users.org/wiki/]
[http://lua-users.org/wiki/ lua-users wiki]


[http://lua-users.org/wiki/SciteScripts/ http://lua-users.org/wiki/SciteScripts]
[http://lua-users.org/wiki/SciTEScripts]


[http://lua-users.org/wiki/SampleCode http://lua-users.org/wiki/SampleCode]
[http://lua-users.org/wiki/SampleCode]


[http://www.autoitscript.com/forum/topic/140881-mouse-hover-call-tips-update-03182013/ AU3Forum: mouse-hover-call-tips]
[http://www.AutoItscript.com/forum/topic/140881-mouse-hover-call-tips-update-03182013/ AutoIt3 Forum: MouseHover --> CallTips]


[http://www.autoitscript.com/forum/topic/152960-scite-lua-tool-to-make-string-variable-from-selected-text/ AU3Forum: scite-lua-tool-to-make-string-variable-from-selected-text]
[http://www.AutoItscript.com/forum/topic/152960-SciTE-lua-tool-to-make-string-variable-from-selected-text/ AutoIt3 Forum: SciTE lua Tool To Make String Variable From Selected Text]


[[Category:SciTE]]
[[Category:SciTE]]

Revision as of 20:52, 4 August 2013

SciTE4AutoIt3 is a specialist editor package based on the excellent SciTE editor. SciTE has been set up to compile AutoIt scripts and has been extended with a multitude of Lua scripts. SciTE4AutoIt3 may be downloaded here: SciTE4AutoIt3. Keep in mind that SciTE4AutoIt3 is not an official package. Direct any bug reports or feature requests to the AutoIt3 forum and not the bug tracker.

Syntax Highlighting

File:Syntax Highlight.png
A demonstration of syntax highlighting using the default theme.

SciTE4AutoIt3 comes with a customized AutoIt3 lexer which enables syntax highlighting. Syntax highlighting enables the colorization of various code elements such as variables, strings, operators, comments etc. Syntax highlighting allows one to differentiate the various code elements such as keywords, variables, strings, control flow structures etc. quickly without having to specifically identify the element. To load a custom theme a user may press [Ctrl] + [1] to bring up SciTEConfig. When the Color Settings tab is selected a button labeled 'New Scheme' will appear at the bottom. Alternatively, the colors may be customized individually.

Some options that are available for customization include:

  • White Space
  • Comment Line
  • Comment Block
  • Number
  • Function
  • Keyword
  • Macro
  • String

Quick Tips

For anyone not familiar with SciTE, here are a few tips and tricks to help easily customize the installation. For any advanced info, visit the SciTE home page.

Help Files

To access the AutoIt3 helpfile the user may press [F1]. To quickly access help information on a specific function, simply click or highlight the desired function and press the [F1] key to bring up the help file on the relevant page. To access the SciTE4AutoIt3 helpfile the user may press [ctrl] + [F1]. For SciTE related help, use the key combination [Ctrl] + [F1] to bring up a help file detailing SciTE related help documentation.

Properties Files

With the information below, you will be doing some minor editing to SciTE's configuration files. It is imperative that you know the hierarchy of SciTE's configuration files. The main files we will be dealing with here are listed below.

Remember there are four properties files used:

SciTE.properties Local properties file which may be present in the same directory as the file being edited. This file overrides any other properties files settings below. This file is user created.
SciTEDirectory.properties Directory properties file which may be present in the same or in a parent directory as the file being edited.

This file overrides all properties setting of the files below, but not the local properties settings aka SciTE.properties. This file is user created.

SciTEUser.properties User properties file, this file's settings override only the global properties settings aka SciTEGlobal.properties.

This file is found under the current logged on users profile directory.

SciTEGlobal.properties All settings in this file can be overridden by any of the above files.

Typically this file should not be edited. Use any of the above methods to implement a setting change. This file can be found in SciTE's installation directory.

Inline Errors

Intentional error prone code used to display the "Inline Error" feature.

In the latest version of SciTE, there exists a new feature called "Inline Errors". Inline Error marks are error messages that will appear in the source code within the Scintilla window.

Inline errors may be quickly toggled using SciTEUser.properties.

Open the SciTE user properties file in a text editor by selecting from the SciTE menu Options. Open User Options File and add the following code to the file.

To disable:

error.inline=0

To enable:

error.inline=1

Selection Highlighting

Syntax Highlighting is a new feature which highlights other instances of the currently highlighted word or string. Due to the colors, sometimes it's hard to tell the selection apart. The default colors may be changed.

The feature may be toggled by editing SciTEUser.properties.

To disable:

highlight.current.word=0

To enable:

highlight.current.word=1

To change the color scheme, add the following to SciTEUser.properties.

highlight.current.word=1

# Edit the following property to change to the desired color.
highlight.current.word.colour=#000040

selection.alpha=50

# Edit the following property to change to the desired color.
selection.back=#F025A8

Colors in the Output Pane

SciTE has a console window which can be used to output information from running scripts. The function ConsoleWrite may be used in an AutoIt script to output text to the console. The colors of the text may be altered by prepending a string with special characters.

For example:

ConsoleWrite("This is plain text" & @LF)
ConsoleWrite("> This text will have a different color." & @LF)
ConsoleWrite("+ This text will have a different color." & @LF)
ConsoleWrite("- This text will have a different color." & @LF)
ConsoleWrite("! This text will have a different color." & @LF)

Debugging Code Easily

dbg("This is a test")
dbg("Jump to this line")
dbg("just by clicking my output line")

Func dbg($msg, $error = @error, $extended = @extended, $erl = @ScriptLineNumber)
    ConsoleWrite("(" & $erl & ") : = (" & $error & ")(" & $extended & ") " & $msg & @LF)
    If $error <> 0 Then SetError($error, $extended, $error)
    Return $error
EndFunc   ;==>dbg

AutoIt3Wrapper

AutoIt3Wrapper directives allow for in depth control of the compilation and interpretation of AutoIt scripts. Some of these can be very useful under different circumstances. See AutoIt3Wrapper Directives for a full list of directives and their descriptions.

Obfuscator

Obfuscator may be used to strip away unused functions and global variables from the script prior to compilation. Functions and variables may be renamed to shorter three character names to save space and to provide some measure of obscurity. Note that Obfuscator is not guaranteed protection against decompilation.

Stripping Excess Code

For instance, if you have several includes, then you can often strip thousands of lines from your script using Obfuscator:

#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0

On a medium sized script, results are often like this:

>Running Obfuscator (1.0.27.0)  from:C:\Program Files\AutoIt3\SciTE cmdline:
- Iteration 1 Strip Functions result: Output  2580 lines and stripped 6741 lines
- Iteration 2 Strip Variables result: Output  1585 lines and stripped 950 lines
- Iteration 3 Strip Variables result: Output  1566 lines and stripped 19 lines
- Iteration 4 Start the actual Obfuscation.
+> Source    26190 lines 1447980 Characters.
+> Stripped  7710 Func/Var lines and  16862 comment lines, Total 1373871 Characters.
+> Saved     93% lines 94% Characters.
+> Obfuscator v1.0.27.0 finished obfuscating 1566 lines, created:C:\MyScript_Obfuscated.au3

Run_After and Run_Before Commands

Running the exe On Build

Often you are building as a test, so to have to open up Windows Explorer to find the exe is a pain. Furthermore, unless you have a program to do it (or it's a console program) you will not be able to read console info such as the debug messages you put in the exe. The solution is simple:

#AutoIt3Wrapper_Run_After="%out%"

This will run the program and read the console output to the SciTE debug frame.

Creating a Version Directory

When compiling, it is very possible that you want to go back to a previous version. If so, then it is neat to have a directory which will store all previous builds, without the need for you to manually copy and paste every time. Make sure you add these directives in last (after adding resources) as they might not be included in the copied result.

#AutoIt3Wrapper_Run_After=md "%scriptdir%\Versions\%fileversion%"
#AutoIt3Wrapper_Run_After=copy "%in%" "%scriptdir%\Versions\%fileversion%\%scriptfile%%fileversion%.au3"
#AutoIt3Wrapper_Run_After=copy "%out%" "%scriptdir%\Versions\%fileversion%\%scriptfile%%fileversion%.exe"

Using ResHacker

ResHacker is a very important programming tool for extracting and adding resources into executables. It has a very simple command line interface that allows it to be used easily using the "Run_After" directive. Adding a picture to an executable could be done like this:

#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, MyPicture.bmp, BITMAP, RESOURCENAME, 0

NB: Reshacker.exe must be copied into the script directory for this to work.

If you then want to use the resources in your code, there is an excellent Resources UDF which will allow you to access the resources from within the exe.

Adding Original Source Code

When using the above tip on stripping excess code, the new source is not readable. As a result, using the standard directive for saving the source:

#AutoIt3Wrapper_Res_SaveSource=y

Would add the obfuscated code to the exe, which is not the desired result. The solution is to add it in manually. This code does not require any editing, so you can just copy and paste it in:

#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, %scriptfile%.au3, RCDATA, SOURCE, 0

Extended Reshacker Info

ResHacker doesn't always return with a return code (rc) of not 0 if it fails, to get that info you need to read the ResHacker.log file that is created. This is also pretty simple to do:

#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, MyPicture.bmp, BITMAP, RESOURCENAME, 0
#AutoIt3Wrapper_Run_After=TYPE ResHacker.log

The new output now looks like this:

>Running:ResHacker.exe -add C:\MyScript.exe, C:\MyScript.exe, MyPicture.bmp, BITMAP, RESOURCENAME, 0
>ResHacker.exe -add C:\MyScript.exe, C:\MyScript.exe, MyPicture.bmp, BITMAP, RESOURCENAME, 0 Ended   rc:0
>Running:TYPE ResHacker.log
[19 Jan 2010, 21:26:22]
ResHacker.exe  -add C:\MyScript.exe, C:\MyScript.exe, MyPicture.bmp, BITMAP, RESOURCENAME, 0
 Added: BITMAP,RESOURCENAME,0

Commands completed
>TYPE ResHacker.log Ended   rc:0

And an example of it showing an error:

>ResHacker.exe -add C:\MyScript.exe, C:\MyScript.exe, MyPicture.bmp, BITMAP, RESOURCENAME, 0 Ended   rc:0
>Running:TYPE ResHacker.log
[19 Jan 2010, 21:32:10]
ResHacker.exe  -add C:\MyScript.exe, C:\MyScript.exe, MyPicture.bmp, BITMAP, RESOURCENAME, 0
Error: "MyPicture.bmp" does not exist
>TYPE ResHacker.log Ended   rc:0

As you can see, Reshacker on its own returns rc: 0, usually indicating no error. This would have gone completely unnoticed except for the log file, which shows the error and an explanation.

Other Run_After and Run_Before Commands

You can use any commands you like in the Run_After and Run_Before directives. Examples such as "TYPE" have been shown above.

For a more complete list the following website is very useful: An A-Z Index of the Windows CMD Line

Other Wiki Pages

Adding Utilities to the SciTE Tools Menu

Adding UDFs to AutoIt and SciTE

Useful Lua links and scripts

SciTELua

Lua Website

Programming in Lua

lua-users wiki

[1]

[2]

AutoIt3 Forum: MouseHover --> CallTips

AutoIt3 Forum: SciTE lua Tool To Make String Variable From Selected Text