Hi,
I'm trying to explain a little bit how the compiler and the compiled AHK-EXE is working (as far as I know

).
In the ahk code there are section which are executed when a normal script is run and other sections when the compiled exe is run (#ifdef's). So the most of the code of a compiled exe and the autohotkey.exe are the same.
One difference i.e. is: If the ahk script is started, the autohotkey.exe is loading the script line by line, parses the commands and starts the autorun section.
If the compiled exe is started the script is loaded from the end of the exe, being decrypted, parsed and run.
The compiler:
The autohotkey source project contains a debug/release project and one for the self executing exe. This part is building the AutoHotkeySC.bin file.
The compiler is copying that bin-file to the destination i.e copy AutoHotkeySC.bin -> myselfexecutingscript.exe.
The next steps are done by an closed source dll. The dll is used to read the script, scramble the content and adding the crypted script to the output exe.
I'm sure it is possible to debug the dll and rewrite it but I'm not sure if this is allowed so I will not try that approach.
Now you have an exe with the crypted script appended.
Starting the EXE:
After starting the EXE, Autohotkey is using functions of the statically linked dll. The function is allocating memory, loading the script of the end of the exe and decrypt it. Autohotkey will receive a pointer to the memory area where the decrypted script is saved to.
Now autohotkey is reading the script line by line parses it and executes the autoexec section.
The biggest problem is the closed source dll. It is compiled for a windows (95/NT) system and will not run with WinCE. So there are two possibilies:
1. Write your own dll with the same funtions and parameters
2. Completly remove the use of the dll and try to handle it by yourself.
To see soon results I've decided to try it without the dll (I'm not sure now if that was the correct approach)
I've spent more than two months to make the compiler work on WinCE.
The work is still not fully done, it's just an approach if it's possible to make the compiler work.
Another problem: The compiler is opening a lot of files. It's more complicated as I've outlined. The script is copied to the temp-folder, preparsed. Included files are being included, saved to another temp file and then appended to the bin/exe file.
On WinCE the compiler crashes after opening the temp file. I do not know why.
I have permanenty problems with WinCE. The executable crashes a lot of times. Most crashes are stack overflows. Autohotkey is allocating "a lot" of memory
#define LINE_SIZE (16384 + 1) // +1 for terminator. Don't increase LINE_SIZE above 65535 without considering ArgStruct::length's type (WORD).
char xxx[LINE_SIZE].
On a PC there's no problem but allocating that on the stack on CE crashes the executable.
So I had to rewrite a lot of lines to allocate that memory with "new" and "delete" it if the memory is not used anymore. Some big functions have a lot of returns. The function is left at dozent places. At every location I have to delete the memory. All I want to say: It lasts some time to make it work somehow.
After 4 weeks without an result I stopped trying to make the compiler work on CE. I've tried to generate the exe on a PC and transfer the exe to the CE device. That was working after some more weeks.
I've created a simple script. You have to change the path to the bin file and the path to the script and the destination path of the exe.
Than you can run the script and it appends the script to the renamed bin file.
Transfer it to the CE device and you will have an AHK-EXE with your script.
Be aware: The script is appended readable !!! No scrambling / crypting at the moment.
With that approach (running an ahk script to generate an exe) it should be possible to "compile" a script without a PC just on your CE device.
Another trap was the coding. On Windows most editors are generating text files. On CE the script must be saved in unicode format!!
If you want to generate an AHK EXE for your CE device with my script you MUST save your script in unicode format !!!
My script is just a very small one that does the job without any convenience.
I hope a member of the community will have the time and motivation to write a small convenient GUI
-------------------------------------------------------------------------
I have to apologize for many things:
I've created a lot of dlls for Autohotkey most without convenient scripts/wrappers so newbies can't use them easily. I've spent toooo much time on the dlls (some time I have should used with my family).
I've tried to prove that some things are working and doing the rough stuff. I never focused on the easy use of that stuff (no time / no motivation...)
I have so many interests and as most other people too less time. So my time has to be shared between ahk and about 7 other projects. My rare work on ahk does not mean I've lost interest it just means there's no time left. Sorry for that.
Why have I started to compile Autohotkey for CE devices?
As I wrote in my post, I'm owning a navigation system with CE. I'm trying a lot of things, searching software that runs on that crippled OS and so I'm killing the navigation system permanently. To reinstall all my changes (other navigation gui / software / settings / address book...) lasts about 40 minutes. I've killed it so often, I wished I can automate the installing procedure. But wait... I'm nowing a perfect piece of software. You all know what software I mean. But it doesn't run on CE..... So the idea was born to port it.
The only commands I have needed were Filecopy, Send, Winwaitactive and run. I did not need any gui or other things I have implemented. I've just done the things for you.
I'm not sure if I will continue work on AHKCE. My next idea between hundred others is to make a dll for ahk to control WPF applications. I think WPF is the next big thing. Future (and also a lot of current) software will use it more and more often and we need ahk to work with it.
-------------------------------------------------------------------------
What can be done to crypt scripts with the compiler:
We need i.e a dll or source code which can scramble textfiles. We also need the code to read the scrambled text and decrypt it. I know there are a lot of ready solutions but I haven't searched/googled for them. If we have found a suitable piece of code I can implement that to the autohotkey source.
How can you create an EXE with your favorite script for CE devices?
Download the following ZIP-File and extract it.
You'll find a bin-file and a script.
Open the script and adjust the path to the bin-file, to the script you want to compile and the destination exe.
Now assure that YOUR script is saved in unicode format. Now run my script.
The exe is being generated. Copy the EXE to your device and run it. Voila.
Why is the EXE so huge?
The Windows 95/NT exe is packed with UPX. That is a packer for exes. The exe is still runable without the need to manually extract it. That's one difference to packers like 7z or winrar. I'm sure you can download the WinCE UPX executable and compress your ahk-exe with that, but I haven't tried it.
http://www.autohotkey.net/~Micha/AutohotkeyCE/AHKCompiler.zip
I'll upload the source soon.
Ciao
Micha